removed unused it.dataPath, related to #32
parent
e74f79eea6
commit
cfec9e3fb3
|
@ -37,7 +37,6 @@ function compile(schema, root, localRefs) {
|
||||||
root: _root,
|
root: _root,
|
||||||
schemaPath: '',
|
schemaPath: '',
|
||||||
errorPath: '""',
|
errorPath: '""',
|
||||||
dataPath: '',
|
|
||||||
RULES: RULES,
|
RULES: RULES,
|
||||||
validate: validateGenerator,
|
validate: validateGenerator,
|
||||||
util: util,
|
util: util,
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
for (var i{{=$lvl}} = {{=startFrom}}; i{{=$lvl}} < {{=$data}}.length; i{{=$lvl}}++) {
|
for (var i{{=$lvl}} = {{=startFrom}}; i{{=$lvl}} < {{=$data}}.length; i{{=$lvl}}++) {
|
||||||
{{
|
{{
|
||||||
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[i' + $lvl + ']';
|
|
||||||
var $passData = $data + '[i' + $lvl + ']';
|
var $passData = $data + '[i' + $lvl + ']';
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ var {{=$valid}};
|
||||||
$it.schema = $sch;
|
$it.schema = $sch;
|
||||||
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
||||||
$it.errorPath = (it.errorPath + ' + "[' + $i + ']"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[' + $i + ']"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[' + $i + ']';
|
|
||||||
var $passData = $data + '[' + $i + ']';
|
var $passData = $data + '[' + $i + ']';
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ var valid{{=$it.level}} = true;
|
||||||
$it.schema = $aProperties;
|
$it.schema = $aProperties;
|
||||||
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
||||||
$it.errorPath = it.errorPath;
|
$it.errorPath = it.errorPath;
|
||||||
$it.dataPath = it.dataPath + '[key' + $lvl + ']';
|
|
||||||
var $passData = $data + '[key' + $lvl + ']';
|
var $passData = $data + '[key' + $lvl + ']';
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -102,7 +101,6 @@ var valid{{=$it.level}} = true;
|
||||||
, $passData = $data + $prop;
|
, $passData = $data + $prop;
|
||||||
$it.schemaPath = $schemaPath + $prop;
|
$it.schemaPath = $schemaPath + $prop;
|
||||||
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + $prop;
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{ var $code = it.validate($it); }}
|
{{ var $code = it.validate($it); }}
|
||||||
|
@ -145,7 +143,6 @@ var valid{{=$it.level}} = true;
|
||||||
if (/{{= it.util.escapeRegExp($pProperty) }}/.test(key{{=$lvl}})) {
|
if (/{{= it.util.escapeRegExp($pProperty) }}/.test(key{{=$lvl}})) {
|
||||||
{{
|
{{
|
||||||
$it.errorPath = (it.errorPath + ' + "[\'" + key' + $lvl + ' + "\']"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[\'" + key' + $lvl + ' + "\']"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[key' + $lvl + ']';
|
|
||||||
var $passData = $data + '[key' + $lvl + ']';
|
var $passData = $data + '[key' + $lvl + ']';
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
} {{? $breakOnError }} else { {{?}}
|
} {{? $breakOnError }} else { {{?}}
|
||||||
#}}
|
#}}
|
||||||
|
|
||||||
{{## def._validateRef:_v: {{=_v}}({{=$data}}, (dataPath || '') + {{= it.errorPath }}) #}}
|
{{## def._validateRef:_v: {{=_v}}({{=$data}}, (dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}) #}}
|
||||||
|
|
||||||
{{? $schema == '#' || $schema == '#/' }}
|
{{? $schema == '#' || $schema == '#/' }}
|
||||||
{{? it.isRoot }}
|
{{? it.isRoot }}
|
||||||
|
|
|
@ -49,7 +49,6 @@ module.exports = function anonymous(it) {
|
||||||
$it.schema = $sch;
|
$it.schema = $sch;
|
||||||
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
||||||
$it.errorPath = (it.errorPath + ' + "[' + $i + ']"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[' + $i + ']"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[' + $i + ']';
|
|
||||||
var $passData = $data + '[' + $i + ']';
|
var $passData = $data + '[' + $i + ']';
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
|
@ -70,7 +69,6 @@ module.exports = function anonymous(it) {
|
||||||
$it.schemaPath = it.schemaPath + '.additionalItems';
|
$it.schemaPath = it.schemaPath + '.additionalItems';
|
||||||
out += ' valid' + ($it.level) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') { for (var i' + ($lvl) + ' = ' + ($schema.length) + '; i' + ($lvl) + ' < ' + ($data) + '.length; i' + ($lvl) + '++) { ';
|
out += ' valid' + ($it.level) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') { for (var i' + ($lvl) + ' = ' + ($schema.length) + '; i' + ($lvl) + ' < ' + ($data) + '.length; i' + ($lvl) + '++) { ';
|
||||||
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[i' + $lvl + ']';
|
|
||||||
var $passData = $data + '[i' + $lvl + ']';
|
var $passData = $data + '[i' + $lvl + ']';
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
|
@ -92,7 +90,6 @@ module.exports = function anonymous(it) {
|
||||||
$it.schemaPath = $schemaPath;
|
$it.schemaPath = $schemaPath;
|
||||||
out += ' for (var i' + ($lvl) + ' = ' + (0) + '; i' + ($lvl) + ' < ' + ($data) + '.length; i' + ($lvl) + '++) { ';
|
out += ' for (var i' + ($lvl) + ' = ' + (0) + '; i' + ($lvl) + ' < ' + ($data) + '.length; i' + ($lvl) + '++) { ';
|
||||||
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[" + i' + $lvl + ' + "]"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[i' + $lvl + ']';
|
|
||||||
var $passData = $data + '[i' + $lvl + ']';
|
var $passData = $data + '[i' + $lvl + ']';
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
|
|
|
@ -75,7 +75,6 @@ module.exports = function anonymous(it) {
|
||||||
$it.schema = $aProperties;
|
$it.schema = $aProperties;
|
||||||
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
||||||
$it.errorPath = it.errorPath;
|
$it.errorPath = it.errorPath;
|
||||||
$it.dataPath = it.dataPath + '[key' + $lvl + ']';
|
|
||||||
var $passData = $data + '[key' + $lvl + ']';
|
var $passData = $data + '[key' + $lvl + ']';
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
|
@ -108,7 +107,6 @@ module.exports = function anonymous(it) {
|
||||||
$passData = $data + $prop;
|
$passData = $data + $prop;
|
||||||
$it.schemaPath = $schemaPath + $prop;
|
$it.schemaPath = $schemaPath + $prop;
|
||||||
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + $prop;
|
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
$code = it.util.varReplace($code, $nextData, $passData);
|
$code = it.util.varReplace($code, $nextData, $passData);
|
||||||
|
@ -142,7 +140,6 @@ module.exports = function anonymous(it) {
|
||||||
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
|
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
|
||||||
out += ' for (var key' + ($lvl) + ' in ' + ($data) + ') { if (/' + (it.util.escapeRegExp($pProperty)) + '/.test(key' + ($lvl) + ')) { ';
|
out += ' for (var key' + ($lvl) + ' in ' + ($data) + ') { if (/' + (it.util.escapeRegExp($pProperty)) + '/.test(key' + ($lvl) + ')) { ';
|
||||||
$it.errorPath = (it.errorPath + ' + "[\'" + key' + $lvl + ' + "\']"').replace('" + "', '');
|
$it.errorPath = (it.errorPath + ' + "[\'" + key' + $lvl + ' + "\']"').replace('" + "', '');
|
||||||
$it.dataPath = it.dataPath + '[key' + $lvl + ']';
|
|
||||||
var $passData = $data + '[key' + $lvl + ']';
|
var $passData = $data + '[key' + $lvl + ']';
|
||||||
var $code = it.validate($it);
|
var $code = it.validate($it);
|
||||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||||
|
|
|
@ -12,15 +12,27 @@ module.exports = function anonymous(it) {
|
||||||
if ($schema == '#' || $schema == '#/') {
|
if ($schema == '#' || $schema == '#/') {
|
||||||
if (it.isRoot) {
|
if (it.isRoot) {
|
||||||
if ($breakOnError && it.wasTop) {
|
if ($breakOnError && it.wasTop) {
|
||||||
out += ' if (! ' + ('validate') + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) return false; else { ';
|
out += ' if (! ' + ('validate') + '(' + ($data) + ', (dataPath || \'\')';
|
||||||
|
if (it.errorPath != '""') {
|
||||||
|
out += ' + ' + (it.errorPath);
|
||||||
|
}
|
||||||
|
out += ') ) return false; else { ';
|
||||||
} else {
|
} else {
|
||||||
out += ' if (! ' + ('validate') + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) { if (vErrors === null) vErrors = ' + ('validate') + '.errors; else vErrors = vErrors.concat(' + ('validate') + '.errors); errors = vErrors.length; } ';
|
out += ' if (! ' + ('validate') + '(' + ($data) + ', (dataPath || \'\')';
|
||||||
|
if (it.errorPath != '""') {
|
||||||
|
out += ' + ' + (it.errorPath);
|
||||||
|
}
|
||||||
|
out += ') ) { if (vErrors === null) vErrors = ' + ('validate') + '.errors; else vErrors = vErrors.concat(' + ('validate') + '.errors); errors = vErrors.length; } ';
|
||||||
if ($breakOnError) {
|
if ($breakOnError) {
|
||||||
out += ' else { ';
|
out += ' else { ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out += ' if (! ' + ('root.refVal[0]') + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) { if (vErrors === null) vErrors = ' + ('root.refVal[0]') + '.errors; else vErrors = vErrors.concat(' + ('root.refVal[0]') + '.errors); errors = vErrors.length; } ';
|
out += ' if (! ' + ('root.refVal[0]') + '(' + ($data) + ', (dataPath || \'\')';
|
||||||
|
if (it.errorPath != '""') {
|
||||||
|
out += ' + ' + (it.errorPath);
|
||||||
|
}
|
||||||
|
out += ') ) { if (vErrors === null) vErrors = ' + ('root.refVal[0]') + '.errors; else vErrors = vErrors.concat(' + ('root.refVal[0]') + '.errors); errors = vErrors.length; } ';
|
||||||
if ($breakOnError) {
|
if ($breakOnError) {
|
||||||
out += ' else { ';
|
out += ' else { ';
|
||||||
}
|
}
|
||||||
|
@ -56,7 +68,11 @@ module.exports = function anonymous(it) {
|
||||||
throw new Error($message);
|
throw new Error($message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out += ' if (! ' + ($refVal) + '(' + ($data) + ', (dataPath || \'\') + ' + (it.errorPath) + ') ) { if (vErrors === null) vErrors = ' + ($refVal) + '.errors; else vErrors = vErrors.concat(' + ($refVal) + '.errors); errors = vErrors.length; } ';
|
out += ' if (! ' + ($refVal) + '(' + ($data) + ', (dataPath || \'\')';
|
||||||
|
if (it.errorPath != '""') {
|
||||||
|
out += ' + ' + (it.errorPath);
|
||||||
|
}
|
||||||
|
out += ') ) { if (vErrors === null) vErrors = ' + ($refVal) + '.errors; else vErrors = vErrors.concat(' + ($refVal) + '.errors); errors = vErrors.length; } ';
|
||||||
if ($breakOnError) {
|
if ($breakOnError) {
|
||||||
out += ' else { ';
|
out += ' else { ';
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@ module.exports = function anonymous(it) {
|
||||||
out += ' validate = function (data, dataPath) { \'use strict\'; var vErrors = null; ';
|
out += ' validate = function (data, dataPath) { \'use strict\'; var vErrors = null; ';
|
||||||
out += ' var errors = 0; ';
|
out += ' var errors = 0; ';
|
||||||
} else {
|
} else {
|
||||||
if (it.opts._debug) {
|
|
||||||
out += ' console.log(\'validate dataPath:\', dataPath); ';
|
|
||||||
}
|
|
||||||
var $lvl = it.level,
|
var $lvl = it.level,
|
||||||
$dataLvl = it.dataLevel,
|
$dataLvl = it.dataLevel,
|
||||||
$data = 'data' + ($dataLvl || '');
|
$data = 'data' + ($dataLvl || '');
|
||||||
|
|
Loading…
Reference in New Issue