Constant values

New in draft 6

The const keyword is used to restrict a value to a single value.

For example, if you only support shipping to the United States for export reasons:

schema
1
{
2
"properties": {
3
"country": {
4
"const": "United States of America"
5
}
6
}
7
}
data
1
{ "country": "United States of America" }
compliant to schema
data
1
{ "country": "Canada" }
not compliant to schema
color openjs foundation logo

Copyright OpenJS Foundation and JSON Schema contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy

© Copyright JSON Schema Organisation 2023