Skip to content

Tests for propertyNames with additionalProperties/unevaluatedProperties #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 14, 2024
24 changes: 24 additions & 0 deletions tests/draft2020-12/additionalProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,29 @@
"valid": true
}
]
},
{
"description": "additionalProperties with propertyNames",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"maxLength": 5
},
"additionalProperties":{
"type": "number"
}
},
"tests": [
{
"description": "Valid against both keywords",
"data": {"apple": 4},
"valid": true
},
{
"description": "Valid against propertyNames, but not unevaluatedProperties",
"data": { "fig": 2, "pear": "available" },
"valid": false
}
]
}
]
2 changes: 1 addition & 1 deletion tests/draft2020-12/propertyNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@
}
]
}
]
]
30 changes: 30 additions & 0 deletions tests/draft2020-12/unevaluatedProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -1564,5 +1564,35 @@
"valid": false
}
]
},
{
"description": "unevaluatedProperties with propertyNames",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties":{
"banana":{
"const": "available"
}
},
"propertyNames": {
"pattern": "^[a-b]"
},
"unevaluatedProperties":{
"type": "number"
}

},
"tests": [
{
"description": "Valid against all constraints",
"data": { "banana": "available", "apple": 4 },
"valid": true
},
{
"description": "valid against propertyNames, but not unevaluatedProperties",
"data": { "banana": "available", "apple": true },
"valid": false
}
]
}
]
Loading