Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"requiredProperties" keyword #846

Open
@awwright

Description

When accepting JSON documents for submission, it is frequently the case the documents are objects that have at least one property that is required, such as an ID or name field.

As an authoring convenience, JSON Schema should have a "requiredProperties" keyword that is similar to "properties" in that it defines a sub-schema to apply to the respective properties; but in addition, each of those properties must exist, similar to the "required" keyword.

This:

{
 "requiredProperties": {
 "name": { "type": "string", "minLength":1 }
 }
}

Would be the same as this:

{
 "required": ["name"],
 "properties": {
 "name": { "type": "string", "minLength":1 }
 }
}

Alternatively, this functionality could be built into the "required" keyword (so that "required" accepts an array or an object). This may even be preferable, since older validators will (usually) bail if they see an object where an array is expected:

{
 "required": {
 "name": { "type": "string", "minLength":1 }
 }
}

Examples of confused users:

This issue is intended to restate and close #659 #681 #734

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    AltStyle によって変換されたページ (->オリジナル) /