Properties and required - sgpinkus/json-schema GitHub Wiki

THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.



Description

An object instance is valid against these two keywords if and only if it contains all required members defined by these two keywords. See below.

Valid values

The value of the properties keyword MUST be an object.

This object's values MUST be objects. Furthermore, these objects MUST be valid JSON Schemas.

One or more of these schema values MAY contain a required keyword. In this case, this keyword's value MUST be a boolean. If the schema does not contain this keyword, implementations MAY consider this keyword as being present with boolean value false.

Note

Strictly speaking, required is a strange beast because it has no meaning in and of itself. It only has a meaning with regards to the enclosing keyword, and only if this keyword is indeed properties. For instance, this is a perfectly legal schema:

{
    "items": { "required": true }
}

but required here serves no purpose.

Example

Considering this schema:

{
    "properties": {
        "a": { "required": true },
        "b": { "required": false }
    }
}

then the following instance is valid:

{
    "a": "foo"
}

but the following is not:

{
    "b": "meh"
}
⚠️ **GitHub.com Fallback** ⚠️