contains : Schema
contains
SchemaValidation succeeds if the instance contains an element that validates against this schema.
| Value |
This keyword must be set to a valid JSON Schema
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
|---|---|
| Kind | Applicator |
| Applies To | Array |
| Base Dialect | Draft 6 |
| Changed In | None |
| Introduced In | Draft 6 |
| Vocabulary | Validation |
| Specification | https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.6.14 |
| Metaschema | http://json-schema.org/draft-06/schema# |
| Official Tests | draft6/contains.json |
| Default |
{}
|
| Annotation | None |
| Affected By | None |
| Affects | None |
| Also See |
|
The contains keyword restricts
array instances to include one or more items (at any location of the array)
that validate against the given subschema.
Remember that JSON Schema is a constraint-driven language.
Therefore, non-array instances successfully validate against this
keyword. If needed, make use of the type keyword to constraint
the accepted type accordingly.
Examples
{
"$schema": "http://json-schema.org/draft-06/schema#",
"contains": {
"type": "number",
"multipleOf": 2
}
}[ "foo", 2, false, [ "bar" ], -5 ][ "foo", 2, false, 3, 4, [ "bar" ], -5, -3.0 ][ 2, 4, 6, 8, 10, 12 ][ "foo", true ][]"Hello World"