JSON Schema - how do I specify that a boolean value must be false?
As of draft-6, you can use the const
keyword.
It's similar to enum, but only takes one value.
{
"properties": {
"some_flag": { "const": false }
}
}
Use the enum
keyword:
{
"properties": {
"some_flag": { "enum": [ false ] }
}
}
This keyword is designed for such cases. The list of JSON values in an enum is the list of possible values for the currently validated value. Here, there is only one possible value: JSON boolean false.