Skip to content

Handling nulls in instances #573

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 13 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ If you suspect one, please [file an issue](https://github.com/json-schema-org/JS
{
"description": "Invalid: null",
"data": {
"type": null
"type": "null"
},
"valid": false
}
Expand Down
15 changes: 15 additions & 0 deletions tests/draft-next/additionalProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,20 @@
"valid": false
}
]
},
{
"description": "additionalProperties should properly handle null data",
"schema": {
"additionalProperties": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft-next/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,20 @@
"valid": false
}
]
},
{
"description": "items should properly handle null data",
"schema": {
"items": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft-next/patternProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,20 @@
"valid": true
}
]
},
{
"description": "patternProperties should properly handle null data",
"schema": {
"patternProperties": {
"^.*bar$": {"type": "null"}
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foobar": null},
"valid": true
}
]
}
]
17 changes: 17 additions & 0 deletions tests/draft-next/prefixItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,22 @@
"valid": true
}
]
},
{
"description": "prefixItems should properly handle null data",
"schema": {
"prefixItems": [
{
"type": "null"
}
]
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft-next/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,20 @@
"valid": false
}
]
},
{
"description": "properties should properly handle null data",
"schema": {
"properties": {
"foo$": {"type": "null"}
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,20 @@
"valid": false
}
]
},
{
"description": "additionalItems should properly handle null data",
"schema": {
"additionalItems": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/additionalProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,20 @@
"valid": false
}
]
},
{
"description": "additionalProperties should properly handle null data",
"schema": {
"additionalProperties": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/contains.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,20 @@
"valid": false
}
]
},
{
"description": "contains should properly handle null data",
"schema": {
"contains": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
32 changes: 32 additions & 0 deletions tests/draft2019-09/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,37 @@
"valid": false
}
]
},
{
"description": "single-form items should properly handle null data",
"schema": {
"items": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
},
{
"description": "array-form items should properly handle null data",
"schema": {
"items": [
{
"type": "null"
}
]
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/patternProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,20 @@
"valid": true
}
]
},
{
"description": "patternProperties should properly handle null data",
"schema": {
"patternProperties": {
"^.*bar$": {"type": "null"}
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foobar": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,20 @@
"valid": false
}
]
},
{
"description": "properties should properly handle null data",
"schema": {
"properties": {
"foo$": {"type": "null"}
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/unevaluatedItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,5 +515,20 @@
"valid": true
}
]
},
{
"description": "unevaluatedItems should properly handle null data",
"schema": {
"unevaluatedItems": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2019-09/unevaluatedProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -1343,5 +1343,20 @@
"valid": true
}
]
},
{
"description": "unevaluatedProperties should properly handle null data",
"schema": {
"unevaluatedProperties": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2020-12/additionalProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,20 @@
"valid": false
}
]
},
{
"description": "additionalProperties should properly handle null data",
"schema": {
"additionalProperties": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foo": null},
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2020-12/contains.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,20 @@
"valid": false
}
]
},
{
"description": "contains should properly handle null data",
"schema": {
"contains": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2020-12/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,20 @@
"valid": false
}
]
},
{
"description": "items should properly handle null data",
"schema": {
"items": {
"type": "null"
}
},
"tests": [
{
"description": "null properties allowed",
"data": [ null ],
"valid": true
}
]
}
]
15 changes: 15 additions & 0 deletions tests/draft2020-12/patternProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,20 @@
"valid": true
}
]
},
{
"description": "patternProperties should properly handle null data",
"schema": {
"patternProperties": {
"^.*bar$": {"type": "null"}
}
},
"tests": [
{
"description": "null properties allowed",
"data": {"foobar": null},
"valid": true
}
]
}
]
Loading