Skip to content

Added new "requiredProperties" keyword to supersede the "required" keyword #681

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions jsonschema-validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,34 @@
</t>
<t>
Omitting this keyword has the same behavior as an empty array.
<cref>
This keyword should be deprecated.
</cref>
</t>
</section>

<section title="requiredProperties">
<t>
The value of this keyword MUST be either a boolean or an array.
If it is an array, elements of this array, if any, MUST be strings,
and MUST be unique.
</t>
<t>
If this keyword is an array, an object instance is valid against this
keyword if every item in the array is the name of a property in the
instance.
</t>
<t>
If this keyword has boolean value true, and the "properties" keyword is
present in the same subschema, an object instance is valid against this
keyword if for every name within the "properties" keyword's value a
property with the same name is present in the instance.
</t>
<t>
Omitting this keyword, setting this keyword with boolean value false,
or setting this keyword with boolean value true when the "properties"
keyword is not present in the same subschema, has the same behavior as
an empty array.
</t>
</section>

Expand Down
11 changes: 10 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,16 @@
"contains": { "$recursiveRef": "#" },
"maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
"minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/$defs/stringArray" },
"required": {
"$comment": "This keyword is deprecated, schema authors should use \"requiredProperties\" instead",
"$ref": "#/$defs/stringArray"
},
"requiredProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#/$defs/stringArray" }
]
},
"additionalProperties": { "$recursiveRef": "#" },
"properties": {
"type": "object",
Expand Down