replace hasOwnProperty with !== undefined

master
Evgeny Poberezkin 2015-06-05 19:08:11 +01:00
parent f47d821418
commit 1a6e9c8d63
3 changed files with 4 additions and 4 deletions

View File

@ -95,7 +95,7 @@ var {{=$valid}} = true;
}}
{{? $breakOnError }} {{=$valid}} = true; {{?}}
if ({{=$data}}.hasOwnProperty('{{= $propertyKey }}')) {
if ({{=$data}}['{{= $propertyKey }}'] !== undefined) {
{{ /* TODO cache data types and paths by keys for patternProperties */ }}
{{ var $useKey = '"' + $propertyKey + '"'; }}
{{# def.validateProperty:$useKey }}

View File

@ -4,13 +4,13 @@
{{? $schema.length <= 100 }}
{{=$valid}} = {{~ $schema:$property:$i }}
{{? $i}} && {{?}}
{{=$data}}.hasOwnProperty('{{= it.escapeQuotes($property) }}')
{{=$data}}['{{= it.escapeQuotes($property) }}'] !== undefined
{{~}};
{{??}}
var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
for (var i{{=$lvl}} = 0; i{{=$lvl}} < schema{{=$lvl}}.length; i{{=$lvl}}++) {
{{=$valid}} = data.hasOwnProperty(schema{{=$lvl}}[i{{=$lvl}}]);
{{=$valid}} = data[schema{{=$lvl}}[i{{=$lvl}}]] !== undefined;
if (!{{=$valid}}) break;
}
{{?}}

View File

@ -1,6 +1,6 @@
{
"name": "ajv",
"version": "0.2.2",
"version": "0.2.3",
"description": "Another JSON schema Validator",
"main": "lib/ajv.js",
"scripts": {