Skip to content

Commit f5f6dec

Browse files
committed
Allow contains to apply to objects as well as arrays
1 parent 6008145 commit f5f6dec

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

jsonschema-core.xml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,18 +2342,26 @@
23422342
been found, in order to collect annotations for use by other keywords.
23432343
This is to ensure that all possible annotations are collected.
23442344
</t>
2345+
<t>
2346+
An object instance is valid against "contains" if at least one of
2347+
its property values is valid against the given schema. The subschema
2348+
MUST be applied to every property value even after the first match has
2349+
been found, in order to collect annotations for use by other keywords.
2350+
This is to ensure that all possible annotations are collected.
2351+
</t>
23452352
<t>
23462353
Logically, the validation result of applying the value subschema to each
2347-
item in the array MUST be ORed with "false", resulting in an overall
2348-
validation result.
2354+
item in the array or property in the object MUST be ORed with "false",
2355+
resulting in an overall validation result.
23492356
</t>
23502357
<t>
2351-
This keyword produces an annotation value which is an array of
2352-
the indexes to which this keyword validates successfully when applying
2353-
its subschema, in ascending order. The value MAY be a boolean "true" if
2354-
the subschema validates successfully when applied to every index of the
2355-
instance. The annotation MUST be present if the instance array to which
2356-
this keyword's schema applies is empty.
2358+
This keyword produces an annotation value which is an array of the
2359+
indexes or property names to which this keyword validates successfully
2360+
when applying its subschema, in ascending order. The value MAY be a
2361+
boolean "true" if the subschema validates successfully when applied to
2362+
every index or property value of the instance. The annotation MUST be
2363+
present if the instance array or object to which this keyword's schema
2364+
applies is empty.
23572365
</t>
23582366
</section>
23592367
</section>

jsonschema-validation.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@
413413
then this keyword has no effect.
414414
</t>
415415
<t>
416-
An instance array is valid against "maxContains" in two ways, depending on
417-
the form of the annotation result of an adjacent
416+
An instance array or object is valid against "maxContains" in two ways,
417+
depending on the form of the annotation result of an adjacent
418418
<xref target="json-schema">"contains"</xref> keyword. The first way is if
419419
the annotation result is an array and the length of that array is less than
420420
or equal to the "maxContains" value. The second way is if the annotation
421-
result is a boolean "true" and the instance array length is less than or
422-
equal to the "maxContains" value.
421+
result is a boolean "true" and the instance length is less than or equal to
422+
the "maxContains" value.
423423
</t>
424424
</section>
425425

@@ -432,13 +432,13 @@
432432
then this keyword has no effect.
433433
</t>
434434
<t>
435-
An instance array is valid against "minContains" in two ways, depending on
436-
the form of the annotation result of an adjacent
435+
An instance array or object is valid against "minContains" in two ways,
436+
depending on the form of the annotation result of an adjacent
437437
<xref target="json-schema">"contains"</xref> keyword. The first way is if
438438
the annotation result is an array and the length of that array is greater
439439
than or equal to the "minContains" value. The second way is if the
440-
annotation result is a boolean "true" and the instance array length is
441-
greater than or equal to the "minContains" value.
440+
annotation result is a boolean "true" and the instance length is greater
441+
than or equal to the "minContains" value.
442442
</t>
443443
<t>
444444
A value of 0 is allowed, but is only useful for setting a range

0 commit comments

Comments
 (0)