How to define a JSON schema that requires at least one of many properties

To require at least one of a set of properties, use required inside a series of anyOf options:

{
    "type": "object",
    "anyOf": [
        {"required": ["id"]},
        {"required": ["email"]}
        // any other properties, in a similar way
    ],
    "properties": {
        // Your actual property definitions here
    }
}

If any of the properties you want is present ("id", "email"), then it will pass the corresponding option in allOf.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)