properties : Object<String, Schema>

properties

Object<String, Schema>

Validation succeeds if, for each name that appears in both the instance and as a name within this keyword’s value, the child instance for that name successfully validates against the corresponding schema.

Value This keyword must be set to an object where each value is a valid JSON Schema Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
Kind Applicator
Applies To Object
Base Dialect Draft 7
Changed In None
Introduced In Draft 1
Vocabulary Validation
Specification https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.6.5.4
Metaschema http://json-schema.org/draft-07/schema#
Official Tests draft7/properties.json
Default {}
Annotation None
Affected By None
Affects
Also See

The properties keyword restricts properties of an object instance, when present, to match their corresponding subschemas definitions.

Remember that JSON Schema is a constraint-driven language. Therefore, non-object instances successfully validate against this keyword. If needed, make use of the type keyword to constraint the accepted type accordingly.

Examples

A schema that constrains object instances to a string and integer property Schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer" }
  }
}
Valid An object value that defines both declared properties and matches the corresponding schemas is valid Instance
{ "name": "John Doe", "age": 50 }
Valid An object value that defines one of the declared properties and matches the corresponding schema is valid Instance
{ "name": "John Doe" }
Valid An empty object value is valid as properties are optional by default Instance
{}
Invalid An object value that defines both declared properties but does not match one of the corresponding schemas is invalid Instance
{ "name": "John Doe", "age": "this should have been an integer" }
Invalid An object value that defines one of the declared properties but does not match its corresponding schema is invalid Instance
{ "name": 999 }
Valid A non-object value is valid Instance
"Hello World"
A schema that constrains object instances to forbid a specific property Schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "forbidden": false,
    "permitted": true
  }
}
Valid An object value that only defines the permitted property is valid Instance
{ "permitted": "anything is valid" }
Valid An object value that defines any additional property is valid as additional properties are permitted by default Instance
{ "foo": "bar", "baz": 2 }
Invalid An object value that only defines the forbidden property is invalid Instance
{ "forbidden": 1 }
Invalid An object value that defines the forbidden property alongside other properties is invalid Instance
{ "forbidden": 1, "permitted": 2 }