Skip to content

Require all described properties. #562

@lordcheeto

Description

@lordcheeto

This keyword indicates that the object must adhere strictly to the defined schema. That is, all defined properties required, and no additional properties allowed.

Example:

{
    "type": "object",
    "properties": {
        "latitude": {
            "type": "number"
        },
        "longitude": {
            "type": "number"
        }
    },
    "strict": true
}

Which would be equivalent to the following schema.

{
    "type": "object",
    "properties": {
        "latitude": {
            "type": "number"
        },
        "longitude": {
            "type": "number"
        }
    },
    "required": [
        "latitude",
        "longitude"
    ],
    "additionalProperties": false
}

While not a huge issue in this trivial example, it would allow objects with many required properties to be expressed less verbosely, and allow for clearer communication of the author's intention.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions