Reference

Value restrictions

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 enum keyword 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 const keyword to force a property to have a single, fixed value. This keyword is more restrictive than enum.

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.

Need Help?

Did you find these docs helpful?

Help us make our docs great!

At JSON Schema, we value docs contributions as much as every other type of contribution!

Still Need Help?

Learning JSON Schema is often confusing, but don't worry, we are here to help!.