JSON Schema - Enumerated and constant values (original) (raw)
The enum and const keywords contribute to data validation by defining limits on the values a property can hold.
- Define a set of values. Use the
enumkeyword to specify a finite set of acceptable values for a property. This ensures that only predefined options are valid. - Define a fixed, single value. Use the
constkeyword to force a property to have a single, fixed value. This keyword is more restrictive thanenum.
Learn more about how to use these keywords with the following resources:
By effectively utilizing these keywords, you can significantly enhance the reliability and accuracy of your JSON data.