Skip to content

Add required + null validation test#827

Merged
jdesrosiers merged 7 commits into
json-schema-org:mainfrom
Shristibot:required-null
Feb 7, 2026
Merged

Add required + null validation test#827
jdesrosiers merged 7 commits into
json-schema-org:mainfrom
Shristibot:required-null

Conversation

@Shristibot
Copy link
Copy Markdown
Contributor

This PR adds a minimal test case for the required keyword validating a null instance.

Per the specification, required only applies to object instances, so null should be considered valid. This test helps catch potential implementation bugs (e.g. treating null as an object in JavaScript).

This change follows the discussion and approval in #821.

@Shristibot Shristibot requested a review from a team as a code owner February 4, 2026 17:30
Copy link
Copy Markdown
Member

@gregsdennis gregsdennis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good. Might as well add a boolean test while you're in here.

Just a comment on the description.

Comment thread tests/draft2019-09/required.json Outdated
"valid": true
},
{
"description": "null is valid",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say "ignores null" to stay in line with the other descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the description for consistency and added a boolean case alongside the existing non-object tests. Thanks!

Copy link
Copy Markdown
Member

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please add the tests to draft-04, draft-06, and v1 as well.

@Shristibot
Copy link
Copy Markdown
Contributor Author

Looks good. Please add the tests to draft-04, draft-06, and v1 as well.

Hi @jdesrosiers , i have added the tests to draft-04, draft-06, and v1 as well.

@jdesrosiers jdesrosiers merged commit 32fa6e2 into json-schema-org:main Feb 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants