refactor: rename option to sourceCode, #293
parent
792590b7b8
commit
d272e05abe
|
@ -44,7 +44,7 @@ function compile(schema, root, localRefs, baseId) {
|
||||||
, defaults = []
|
, defaults = []
|
||||||
, defaultsHash = {}
|
, defaultsHash = {}
|
||||||
, customRules = []
|
, customRules = []
|
||||||
, retainSourceCode = this._opts.retainSourceCode !== false;
|
, keepSourceCode = this._opts.sourceCode !== false;
|
||||||
|
|
||||||
root = root || { schema: schema, refVal: refVal, refs: refs };
|
root = root || { schema: schema, refVal: refVal, refs: refs };
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ function compile(schema, root, localRefs, baseId) {
|
||||||
cv.refVal = v.refVal;
|
cv.refVal = v.refVal;
|
||||||
cv.root = v.root;
|
cv.root = v.root;
|
||||||
cv.$async = v.$async;
|
cv.$async = v.$async;
|
||||||
if (retainSourceCode) cv.sourceCode = v.sourceCode;
|
if (keepSourceCode) cv.sourceCode = v.sourceCode;
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -128,33 +128,32 @@ function compile(schema, root, localRefs, baseId) {
|
||||||
: sourceCode;
|
: sourceCode;
|
||||||
|
|
||||||
var makeValidate = new Function(
|
var makeValidate = new Function(
|
||||||
|
'self',
|
||||||
|
'RULES',
|
||||||
|
'formats',
|
||||||
|
'root',
|
||||||
'refVal',
|
'refVal',
|
||||||
|
'defaults',
|
||||||
|
'customRules',
|
||||||
'co',
|
'co',
|
||||||
'equal',
|
'equal',
|
||||||
'ucs2length',
|
'ucs2length',
|
||||||
'root',
|
|
||||||
'formats',
|
|
||||||
'customRules',
|
|
||||||
'ValidationError',
|
'ValidationError',
|
||||||
'RULES',
|
|
||||||
'defaults',
|
|
||||||
'self',
|
|
||||||
'validate',
|
|
||||||
validateCode
|
validateCode
|
||||||
);
|
);
|
||||||
|
|
||||||
validate = makeValidate(
|
validate = makeValidate(
|
||||||
|
self,
|
||||||
|
RULES,
|
||||||
|
formats,
|
||||||
|
root,
|
||||||
refVal,
|
refVal,
|
||||||
|
defaults,
|
||||||
|
customRules,
|
||||||
co,
|
co,
|
||||||
equal,
|
equal,
|
||||||
ucs2length,
|
ucs2length,
|
||||||
root,
|
ValidationError
|
||||||
formats,
|
|
||||||
customRules,
|
|
||||||
ValidationError,
|
|
||||||
RULES,
|
|
||||||
defaults,
|
|
||||||
self
|
|
||||||
);
|
);
|
||||||
|
|
||||||
refVal[0] = validate;
|
refVal[0] = validate;
|
||||||
|
@ -169,7 +168,7 @@ function compile(schema, root, localRefs, baseId) {
|
||||||
validate.refVal = refVal;
|
validate.refVal = refVal;
|
||||||
validate.root = isRoot ? validate : _root;
|
validate.root = isRoot ? validate : _root;
|
||||||
if ($async) validate.$async = true;
|
if ($async) validate.$async = true;
|
||||||
if (retainSourceCode) validate.sourceCode = sourceCode;
|
if (keepSourceCode) validate.sourceCode = sourceCode;
|
||||||
|
|
||||||
return validate;
|
return validate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
it.dataPathArr = [undefined];
|
it.dataPathArr = [undefined];
|
||||||
}}
|
}}
|
||||||
|
|
||||||
validate =
|
var validate =
|
||||||
{{? $async }}
|
{{? $async }}
|
||||||
{{? $es7 }}
|
{{? $es7 }}
|
||||||
(async function
|
(async function
|
||||||
|
@ -178,6 +178,8 @@
|
||||||
return errors === 0; {{ /* don't edit, used in replace */ }}
|
return errors === 0; {{ /* don't edit, used in replace */ }}
|
||||||
{{?}}
|
{{?}}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return validate;
|
||||||
{{??}}
|
{{??}}
|
||||||
var {{=$valid}} = errors === errs_{{=$lvl}};
|
var {{=$valid}} = errors === errs_{{=$lvl}};
|
||||||
{{?}}
|
{{?}}
|
||||||
|
|
Loading…
Reference in New Issue