Data
Support for $data keyword
This keyword uses values from data as schema values. Since it can be dangerous to allow arbitrary content inside a schema this keyword is restricted to the following keywords:
minLength, maxLength, pattern,
minimum, maximum, multipleOf, exclusiveMinimum, exclusiveMaximum,
minItems, maxItems, uniqueItems,
required, minProperties, maxProperties,
To use this keyword you must replace the value of the original keyword
with an object having the following structure {"$data": "json-pointer"}
.
The value of the keyword will dynamically resolve to the value extracted by the JSON pointer.
{
"type": "object",
"properties": {
"password": {
"type": "string"
},
"repeat": {
"type": "string",
"const": {"$data": "/password"}
}
}
}
Input | Status |
---|---|
{"password": "a", "repeat": "a"} |
valid |
{"password": "a", "repeat": "b"} |
invalid |
You can disable $data keyword by setting the allowDataKeyword
option to false
.