use properties as properties or indeces correctly in all cases
parent
3b815d6862
commit
0ccf7e73f1
|
@ -7,7 +7,6 @@ module.exports = {
|
|||
checkDataTypes: checkDataTypes,
|
||||
toHash: toHash,
|
||||
getProperty: getProperty,
|
||||
escapeQuotes: escapeQuotes,
|
||||
escapeRegExp: escapeRegExp,
|
||||
ucs2length: ucs2length,
|
||||
varOccurences: varOccurences,
|
||||
|
@ -85,12 +84,7 @@ var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
|||
function getProperty(key) {
|
||||
return IDENTIFIER.test(key)
|
||||
? '.' + key
|
||||
: "['" + key + "']";
|
||||
}
|
||||
|
||||
|
||||
function escapeQuotes(str) {
|
||||
return str.replace(/'/g, "\\'");
|
||||
: "['" + key.replace(/'/g, "\\'") + "']";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ var {{=$errs}} = errors;
|
|||
if ({{=$data}}['{{= $property }}'] !== undefined) {
|
||||
{{
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($property) + "']";
|
||||
$it.schemaPath = $schemaPath + it.util.getProperty($property);
|
||||
}}
|
||||
|
||||
{{= it.validate($it) }}
|
||||
|
|
|
@ -79,9 +79,9 @@ var valid{{=$it.level}} = true;
|
|||
{{? {{# def.nonEmptySchema:$sch}} }}
|
||||
{{
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($propertyKey) + "']";
|
||||
var $prop = it.util.getProperty($propertyKey)
|
||||
, $passData = $data + $prop;
|
||||
$it.schemaPath = $schemaPath + $prop;
|
||||
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
||||
$it.dataPath = it.dataPath + $prop;
|
||||
}}
|
||||
|
|
|
@ -77,7 +77,7 @@ module.exports = function anonymous(it) {
|
|||
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
||||
out += ' valid' + ($it.level) + ' = true; if (' + ($data) + '[\'' + ($property) + '\'] !== undefined) { ';
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($property) + "']";
|
||||
$it.schemaPath = $schemaPath + it.util.getProperty($property);
|
||||
out += ' ' + (it.validate($it)) + ' } ';
|
||||
if ($breakOnError) {
|
||||
out += ' if (valid' + ($it.level) + ') { ';
|
||||
|
|
|
@ -94,9 +94,9 @@ module.exports = function anonymous(it) {
|
|||
var $sch = $schema[$propertyKey];
|
||||
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($propertyKey) + "']";
|
||||
var $prop = it.util.getProperty($propertyKey),
|
||||
$passData = $data + $prop;
|
||||
$it.schemaPath = $schemaPath + $prop;
|
||||
$it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', '');
|
||||
$it.dataPath = it.dataPath + $prop;
|
||||
var $code = it.validate($it);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ajv",
|
||||
"version": "0.5.11",
|
||||
"version": "0.5.12",
|
||||
"description": "Another JSON Schema Validator",
|
||||
"main": "lib/ajv.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue