From abc7e48b24e788d99542f62fcd832bf5e1a696b5 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 19 Apr 2021 13:32:53 -0700 Subject: [PATCH 1/5] Allow contains to apply to objects as well as arrays --- jsonschema-core.xml | 24 ++++++++++++++++-------- jsonschema-validation.xml | 16 ++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index e6b5476e..7165035c 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -2342,18 +2342,26 @@ been found, in order to collect annotations for use by other keywords. This is to ensure that all possible annotations are collected. + + An object instance is valid against "contains" if at least one of + its property values is valid against the given schema. The subschema + MUST be applied to every property value even after the first match has + been found, in order to collect annotations for use by other keywords. + This is to ensure that all possible annotations are collected. + Logically, the validation result of applying the value subschema to each - item in the array MUST be ORed with "false", resulting in an overall - validation result. + item in the array or property in the object MUST be ORed with "false", + resulting in an overall validation result. - This keyword produces an annotation value which is an array of - the indexes to which this keyword validates successfully when applying - its subschema, in ascending order. The value MAY be a boolean "true" if - the subschema validates successfully when applied to every index of the - instance. The annotation MUST be present if the instance array to which - this keyword's schema applies is empty. + This keyword produces an annotation value which is an array of the + indexes or property names to which this keyword validates successfully + when applying its subschema, in ascending order. The value MAY be a + boolean "true" if the subschema validates successfully when applied to + every index or property value of the instance. The annotation MUST be + present if the instance array or object to which this keyword's schema + applies is empty. diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index b8d68d69..71747664 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -410,13 +410,13 @@ then this keyword has no effect. - An instance array is valid against "maxContains" in two ways, depending on - the form of the annotation result of an adjacent + An instance array or object is valid against "maxContains" in two ways, + depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is less than or equal to the "maxContains" value. The second way is if the annotation - result is a boolean "true" and the instance array length is less than or - equal to the "maxContains" value. + result is a boolean "true" and the instance length is less than or equal to + the "maxContains" value. @@ -429,13 +429,13 @@ then this keyword has no effect. - An instance array is valid against "minContains" in two ways, depending on - the form of the annotation result of an adjacent + An instance array or object is valid against "minContains" in two ways, + depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is greater than or equal to the "minContains" value. The second way is if the - annotation result is a boolean "true" and the instance array length is - greater than or equal to the "minContains" value. + annotation result is a boolean "true" and the instance length is greater + than or equal to the "minContains" value. A value of 0 is allowed, but is only useful for setting a range From 46de49986a0094de3cad3e575e4607fb2d8ec06e Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 20 Apr 2021 11:08:30 -0700 Subject: [PATCH 2/5] Move contains to "other" applicator section --- jsonschema-core.xml | 70 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 7165035c..2eec5fe8 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -2330,40 +2330,6 @@ Implementations that do not support annotation collection MUST do so. - -
- - The value of this keyword MUST be a valid JSON Schema. - - - An array instance is valid against "contains" if at least one of - its elements is valid against the given schema. The subschema MUST be - applied to every array element even after the first match has - been found, in order to collect annotations for use by other keywords. - This is to ensure that all possible annotations are collected. - - - An object instance is valid against "contains" if at least one of - its property values is valid against the given schema. The subschema - MUST be applied to every property value even after the first match has - been found, in order to collect annotations for use by other keywords. - This is to ensure that all possible annotations are collected. - - - Logically, the validation result of applying the value subschema to each - item in the array or property in the object MUST be ORed with "false", - resulting in an overall validation result. - - - This keyword produces an annotation value which is an array of the - indexes or property names to which this keyword validates successfully - when applying its subschema, in ascending order. The value MAY be a - boolean "true" if the subschema validates successfully when applied to - every index or property value of the instance. The annotation MUST be - present if the instance array or object to which this keyword's schema - applies is empty. - -
@@ -2458,6 +2424,42 @@
+ +
+
+ + The value of this keyword MUST be a valid JSON Schema. + + + An array instance is valid against "contains" if at least one of + its elements is valid against the given schema. The subschema MUST be + applied to every array element even after the first match has + been found, in order to collect annotations for use by other keywords. + This is to ensure that all possible annotations are collected. + + + An object instance is valid against "contains" if at least one of + its property values is valid against the given schema. The subschema + MUST be applied to every property value even after the first match has + been found, in order to collect annotations for use by other keywords. + This is to ensure that all possible annotations are collected. + + + Logically, the validation result of applying the value subschema to each + item in the array or property in the object MUST be ORed with "false", + resulting in an overall validation result. + + + This keyword produces an annotation value which is an array of the + indexes or property names to which this keyword validates successfully + when applying its subschema, in ascending order. The value MAY be a + boolean "true" if the subschema validates successfully when applied to + every index or property value of the instance. The annotation MUST be + present if the instance array or object to which this keyword's schema + applies is empty. + +
+
From dcd4d2e41eb464b0cf6083f1c5c78c223ed63f05 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 20 Apr 2021 11:09:03 -0700 Subject: [PATCH 3/5] Clarify that "length" applies to objects as well as arrays --- jsonschema-validation.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index 71747664..e1990bcd 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -415,8 +415,8 @@ "contains" keyword. The first way is if the annotation result is an array and the length of that array is less than or equal to the "maxContains" value. The second way is if the annotation - result is a boolean "true" and the instance length is less than or equal to - the "maxContains" value. + result is a boolean "true" and the instance length (number of items or + properties) is less than or equal to the "maxContains" value. @@ -434,8 +434,8 @@ "contains" keyword. The first way is if the annotation result is an array and the length of that array is greater than or equal to the "minContains" value. The second way is if the - annotation result is a boolean "true" and the instance length is greater - than or equal to the "minContains" value. + annotation result is a boolean "true" and the instance length (number of + items or properties) is greater than or equal to the "minContains" value. A value of 0 is allowed, but is only useful for setting a range From 58e42649e88b96c7350e1483f6b2935909d732b0 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Fri, 14 May 2021 11:37:48 -0700 Subject: [PATCH 4/5] Add change log for bhutton-next --- jsonschema-core.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 2eec5fe8..9656e765 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -3851,6 +3851,10 @@ https://example.com/schemas/common#/$defs/count/minimum + + + + "$schema" MAY change for embedded resources From e6519bae41381838a6fb64c491400cb3be8b0b67 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Fri, 14 May 2021 11:40:24 -0700 Subject: [PATCH 5/5] Add to change log "contains" applies to objects --- jsonschema-core.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 9656e765..05712f2c 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -3853,6 +3853,7 @@ https://example.com/schemas/common#/$defs/count/minimum + "contains" now applies to objects as well as arrays