fixed escaping pattern property (fixes #17)

master
Evgeny Poberezkin 2015-06-23 17:25:50 +01:00
parent 6f52f90b04
commit 391d60482c
4 changed files with 25 additions and 3 deletions

View File

@ -119,7 +119,7 @@ var valid{{=$it.level}} = true;
{{? {{# def.nonEmptySchema:$sch}} }}
{{
$it.schema = $sch;
$it.schemaPath = it.schemaPath + '.patternProperties.' + $pProperty;
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
}}
for (var key{{=$lvl}} in {{=$data}}) {

View File

@ -129,7 +129,7 @@ module.exports = function anonymous(it) {
var $sch = $pProperties[$pProperty];
if (it.util.schemaHasRules($sch, it.RULES.all)) {
$it.schema = $sch;
$it.schemaPath = it.schemaPath + '.patternProperties.' + $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) + ')) { ';
$it.errorPath = (it.errorPath + ' + "[\'" + key' + $lvl + ' + "\']"').replace('" + "', '');
$it.dataPath = it.dataPath + '[key' + $lvl + ']';

View File

@ -1,6 +1,6 @@
{
"name": "ajv",
"version": "0.5.10",
"version": "0.5.11",
"description": "Another JSON Schema Validator",
"main": "lib/ajv.js",
"scripts": {

View File

@ -0,0 +1,22 @@
[
{
"description": "escaping pattern property (#17)",
"schema": {
"type" : "object",
"patternProperties": {
"^.+$" : {
"type" : "object",
"required" : ["unit"]
}
},
"additionalProperties" : false
},
"tests": [
{
"description": "empty object",
"data": {},
"valid": true
}
]
}
]