Enumerated values¶
The enum
keyword is used to restrict a value to a fixed set of values.
It must be an array with at least one element, where each element is
unique.
The following is an example for validating street light colors:
You can use enum
even without a type, to accept values of different
types. Let's extend the example to use null
to indicate "off", and
also add 42, just for fun.