Sergei Basharov Sergei Basharov - 1 year ago 126
JSON Question

Can I set exact value in a JSON Schema?

I use JSON Schema to validate app objects against some schema for testing.

I see that I can set

values for a property:

"responseCode": {
"type": "integer",
"minimum": 100,
"maximum": 500

But I couldn't find if I can set an exact required value, like

Is it possible to set it to exactly what I need to validate for?

esp esp
Answer Source

You can:

{ "enum": [123] }

There is a proposal to add the keyword constant in the next standard version:

{ "constant": 123 }

constant is supported by Ajv (a bit of self-promotion here).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download