required : Boolean
required
BooleanAn object instance is valid if the name of the required property exists in the instance.
Value | This keyword is defined in the property definition subschema where a value must be defined within an instance |
---|---|
Kind | Assertion |
Applies To | Object |
Dialect | Draft 3 |
Changed In | Draft 4 |
Introduced In | Draft 3 |
Vocabulary | Core |
Specification | https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf#5.7 |
Metaschema | http://json-schema.org/draft-03/schema# |
Official Tests | draft3/required.json |
Default |
false
|
Annotation | None |
Affected By | None |
Affects | None |
Also See |
|
Examples
Schema with 'required' keyword
Schema
{
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"properties": {
"person": {
"type": "string",
"required": true
}
}
}
Valid
An object instance with the required property defined is valid
Instance
{ "person": "John Doe" }
Invalid
An object instance not containing the required property is invalid
Instance
{ "age": 10 }