-
-
Notifications
You must be signed in to change notification settings - Fork 315
Improve child validation wording from feedback. #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,15 +179,26 @@ | |
|
||
<section title="Validation of primitive types and child values"> | ||
<t> | ||
Two of the primitive types, array and object, allow for child values. The validation of | ||
the primitive type is considered separately from the validation of child instances. | ||
Two of the primitive types, array and object, allow for child values. | ||
The validation of the primitive type is considered separately from | ||
the validation of child instances. | ||
</t> | ||
<t> | ||
For arrays, primitive type validation consists of validating restrictions on length. | ||
For arrays, primitive type validation consists of validating | ||
restrictions on length with "minItems" and "maxItems", while | ||
"items" and "additionalItems" determine which subschemas apply | ||
to which elements of the array. In addition, "uniqueItems" | ||
and "contains" validate array contents as a whole. | ||
</t> | ||
<t> | ||
For objects, primitive type validation consists of validating restrictions on the presence | ||
or absence of property names. | ||
For objects, primitive type validation consists of validating | ||
restrictions on which and how many properties appear with | ||
"required", "minProperties", "maxProperties", "propertyNames", | ||
and the string array form of "dependencies", while "properties", | ||
"patternProperties", and "additionalProperties" determine which | ||
subschemas apply to which object property values. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd consider adding "... and do not directly validate the instance itself.", after reading your explanation at #161 (comment) I found your phrasing there explaining...
to actually be a clearer explanation that the changes you've made. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Relequestual I have made the changes you requested and replaced "validation always succeeds" with "does not directly validate the instance itself." |
||
In addition, the schema form of "dependencies" validates the | ||
object as a whole based on the presence of specific property names. | ||
</t> | ||
</section> | ||
|
||
|
@@ -335,8 +346,8 @@ | |
If absent, it can be considered present with an empty schema. | ||
</t> | ||
<t> | ||
This keyword controls child instance validation. Validation of the | ||
primitive instance type against this keyword always succeeds. | ||
This keyword determines how child instances validate for arrays, | ||
and does not directly validate the immediate instance itself. | ||
</t> | ||
<t> | ||
If "items" is a schema, child validation succeeds if all elements | ||
|
@@ -357,8 +368,8 @@ | |
If absent, it can be considered present with an empty schema. | ||
</t> | ||
<t> | ||
This keyword controls child instance validation. Validation of the | ||
primitive instance type against this keyword always succeeds. | ||
This keyword determines how child instances validate for arrays, | ||
and does not directly validate the immediate instance itself. | ||
</t> | ||
<t> | ||
If "items" is an array of schemas, child validation succeeds | ||
|
@@ -473,16 +484,17 @@ | |
MUST be a valid JSON Schema. | ||
</t> | ||
<t> | ||
If absent, it can be considered the same as an empty object. | ||
If absent, it can be considered the same as an empty schema. | ||
</t> | ||
<t> | ||
This keyword controls child instance validation. Validation of the | ||
primitive instance type against this keyword always succeeds. | ||
This keyword determines how child instances validate for objects, | ||
and does not directly validate the immediate instance itself. | ||
</t> | ||
<t> | ||
Child validation succeeds if, for each name that appears in both | ||
the instance and as a name within this keyword's value, the instance | ||
value successfully validates against the corresponding schema. | ||
the instance and as a name within this keyword's value, the child | ||
instance for that name successfully validates against the | ||
corresponding schema. | ||
</t> | ||
</section> | ||
|
||
|
@@ -494,11 +506,13 @@ | |
MUST be a valid JSON Schema. | ||
</t> | ||
<t> | ||
If absent, it can be considered the same as an empty object. | ||
If absent, it can be considered the same as an empty schema. | ||
</t> | ||
<t> | ||
This keyword controls child instance validation. Validation of the | ||
primitive instance type against this keyword always succeeds. | ||
This keyword determines how child instances validate for objects, | ||
and does not directly validate the immediate instance itself. | ||
Validation of the primitive instance type against this keyword | ||
always succeeds. | ||
</t> | ||
<t> | ||
Child validation succeeds if, for each instance name that matches any | ||
|
@@ -517,8 +531,8 @@ | |
an empty schema as a value. | ||
</t> | ||
<t> | ||
This keyword controls child instance validation. Validation of the | ||
primitive instance type against this keyword always succeeds. | ||
This keyword determines how child instances validate for objects, | ||
and does not directly validate the immediate instance itself. | ||
</t> | ||
<t> | ||
Child validation with "additionalProperties" applies only to the child | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the phrasing
a little confusing. It may be just my lack of understanding though. Can you expand on this section please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those keywords tell you whether a given subschema applies to a given child instance or not.
This is the critically important point that differentiates these keywords from all others. Rather than applying rules to the immediate instance and producing a validation rule based on that, these keywords just say "the validation outcome of this keyword is simply the result of applying the subschema to certain child instances", and give you rules on which child instances are affected by the subschema.
Does that help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's extremely important because implementing these is different from implementing other keywords. There are basically four types of validation keywords:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also highlights how these keywords (like "allOf"/"anyOf"/"oneOf"/"not") are important for more than just validation. All other vocabularies, such as hyper-schema, are pretty much useless without these keywords as they are the only way to apply other vocabularies to complex instances. The core vocabulary ("$schema", "$id", "$ref") does not provide any such mechanism, and vocabularies such as hyper-schema should not re-implement the process. These keywords and the logical keywords have implications far beyond validation.