refactor: rename option to sourceCode, #293

master
Evgeny Poberezkin 2016-09-06 21:29:39 +01:00
parent 792590b7b8
commit d272e05abe
2 changed files with 19 additions and 18 deletions

View File

@ -44,7 +44,7 @@ function compile(schema, root, localRefs, baseId) {
, defaults = []
, defaultsHash = {}
, customRules = []
, retainSourceCode = this._opts.retainSourceCode !== false;
, keepSourceCode = this._opts.sourceCode !== false;
root = root || { schema: schema, refVal: refVal, refs: refs };
@ -66,7 +66,7 @@ function compile(schema, root, localRefs, baseId) {
cv.refVal = v.refVal;
cv.root = v.root;
cv.$async = v.$async;
if (retainSourceCode) cv.sourceCode = v.sourceCode;
if (keepSourceCode) cv.sourceCode = v.sourceCode;
}
return v;
} finally {
@ -128,33 +128,32 @@ function compile(schema, root, localRefs, baseId) {
: sourceCode;
var makeValidate = new Function(
'self',
'RULES',
'formats',
'root',
'refVal',
'defaults',
'customRules',
'co',
'equal',
'ucs2length',
'root',
'formats',
'customRules',
'ValidationError',
'RULES',
'defaults',
'self',
'validate',
validateCode
);
validate = makeValidate(
self,
RULES,
formats,
root,
refVal,
defaults,
customRules,
co,
equal,
ucs2length,
root,
formats,
customRules,
ValidationError,
RULES,
defaults,
self
ValidationError
);
refVal[0] = validate;
@ -169,7 +168,7 @@ function compile(schema, root, localRefs, baseId) {
validate.refVal = refVal;
validate.root = isRoot ? validate : _root;
if ($async) validate.$async = true;
if (retainSourceCode) validate.sourceCode = sourceCode;
if (keepSourceCode) validate.sourceCode = sourceCode;
return validate;
}

View File

@ -34,7 +34,7 @@
it.dataPathArr = [undefined];
}}
validate =
var validate =
{{? $async }}
{{? $es7 }}
(async function
@ -178,6 +178,8 @@
return errors === 0; {{ /* don't edit, used in replace */ }}
{{?}}
});
return validate;
{{??}}
var {{=$valid}} = errors === errs_{{=$lvl}};
{{?}}