fix: schema "dependencies" with property containing single quotes, closes #413

master
Evgeny Poberezkin 2017-02-12 00:21:53 +00:00
parent af458d3460
commit 8413890875
2 changed files with 30 additions and 1 deletions

View File

@ -47,7 +47,7 @@ var missing{{=$lvl}};
{{? {{# def.nonEmptySchema:$sch }} }}
{{=$nextValid}} = true;
if ({{=$data}}['{{= $property }}'] !== undefined) {
if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined) {
{{
$it.schema = $sch;
$it.schemaPath = $schemaPath + it.util.getProperty($property);

View File

@ -0,0 +1,29 @@
[
{
"description": "JSON with control characters - 'dependencies'",
"schema": {
"dependencies": {
"foo'bar": {
"not": { "required": ["bar"] }
}
}
},
"tests": [
{
"description": "valid object",
"data": {
"foo'bar": 1
},
"valid": true
},
{
"description": "invalid object",
"data": {
"foo'bar": 1,
"bar": 2
},
"valid": false
}
]
}
]