fixed escaping pattern property (fixes #17)
parent
6f52f90b04
commit
391d60482c
|
@ -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}}) {
|
||||
|
|
|
@ -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 + ']';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ajv",
|
||||
"version": "0.5.10",
|
||||
"version": "0.5.11",
|
||||
"description": "Another JSON Schema Validator",
|
||||
"main": "lib/ajv.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue