Enum - sgpinkus/json-schema GitHub Wiki
THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.
NOTE: The enum
feature was included in Draft 04 (if not earlier).
An instance will be valid with regards to this keyword if and only if it is exactly equal to one of the elements in this keyword's value.
For a definition of JSON value equality, see uniqueItems.
The value for this keyword MUST be an array. This array MUST have at least one element.
No conditions are imposed on the elements of the array.
Given the following schema:
{
"enum": [ true, 31.4, "hello world", [ 1, 2, 3, { "a", "b" } ], null, { "x": [ 31.5, 3, 0 ] } ]
}
the following instances are valid:
- null;
- { "x": [ 31.5, 3, 0 ] };
- "hello world";
the following instances are invalid:
- [ null ];
- { "x": [ 31.5, 3, 0.0 ] } (it is invalid: even though 0 and 0.0 are equal mathematically speaking, their JSON representation differs);
- "hello, world";
- [ 1, 3, 2, { "a", "b" } ] (array equality dictates that elements be equal at their respective positions).