JSON Schema - Constant values (original) (raw)

starNew 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:

 logo-white schema

{ "properties": { "country": { "const": "United States of America" } }}

data

{ "country": "United States of America" }

Checkmark iconcompliant to schema

data

{ "country": "Canada" }

Error iconnot compliant to schema

Enumerated values

Schema annotations and comments

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!

Edit this page on Github

Learn how to contribute

Still Need Help?

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

Ask the community on GitHub

Ask the community on Slack