Skip to content

Commit e44120f

Browse files
committed
Allow contains to apply to objects as well as arrays
1 parent add836e commit e44120f

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

jsonschema-core.xml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,20 @@
23802380
even if none of its elements is valid against the given schema.
23812381
</t>
23822382
<t>
2383-
This keyword produces an annotation value which is an array of
2384-
the indexes to which this keyword validates successfully when applying
2385-
its subschema, in ascending order. The value MAY be a boolean "true" if
2386-
the subschema validates successfully when applied to every index of the
2387-
instance. The annotation MUST be present if the instance array to which
2388-
this keyword's schema applies is empty.
2383+
An object instance is valid against "contains" if at least one of
2384+
its properties is valid against the given schema,
2385+
except when "minContains" is present and has a value of 0, in which
2386+
case an object instance MUST be considered valid against the "contains" keyword,
2387+
even if none of its property values is valid against the given schema.
2388+
</t>
2389+
<t>
2390+
This keyword produces an annotation value which is an array of the
2391+
indexes or property names to which this keyword validates successfully
2392+
when applying its subschema, in ascending order. The value MAY be a
2393+
boolean "true" if the subschema validates successfully when applied to
2394+
every index or property value of the instance. The annotation MUST be
2395+
present if the instance array or object to which this keyword's schema
2396+
applies is empty.
23892397
</t>
23902398
<t>
23912399
This annotation affects the behavior of "unevaluatedItems" in the

jsonschema-validation.xml

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

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

0 commit comments

Comments
 (0)