Sergei Basharov Sergei Basharov - 5 months ago 49
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

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).