|
156 | 156 |
|
157 | 157 | <section title="General validation considerations">
|
158 | 158 |
|
159 |
| - <section title="Keywords and instance primitive types"> |
| 159 | + <section title="Constraints and missing keywords"> |
160 | 160 | <t>
|
161 |
| - Most validation keywords only limit the range of values within a certain primitive type. |
162 |
| - When the primitive type of the instance is not of the type targeted by the keyword, the |
163 |
| - validation succeeds. |
| 161 | + Each JSON Schema validation keyword adds constraints that |
| 162 | + an instance must satisfy in order to successfully validate. |
164 | 163 | </t>
|
165 | 164 | <t>
|
166 |
| - For example, the "maxLength" keyword will only restrict certain strings (that are too long) from being valid. |
167 |
| - If the instance is a number, boolean, null, array, or object, the keyword passes validation. |
168 |
| - </t> |
| 165 | + Validation keywords that are missing never restrict validation. |
| 166 | + In some cases, this no-op behavior is identical to a keyword that |
| 167 | + exists with certain values, and these values are noted where relevant. |
| 168 | + </t> |
| 169 | + <figure> |
| 170 | + <preamble> |
| 171 | + From this principle, it follows that all JSON values |
| 172 | + successfully validate against the empty schema: |
| 173 | + </preamble> |
| 174 | + <artwork> |
| 175 | +<![CDATA[ |
| 176 | +{} |
| 177 | +]]> |
| 178 | + </artwork> |
| 179 | + </figure> |
| 180 | + <figure> |
| 181 | + <preamble> |
| 182 | + Similarly, it follows that no JSON value successfully |
| 183 | + validates against the empty schema's negation: |
| 184 | + </preamble> |
| 185 | + <artwork> |
| 186 | +<![CDATA[ |
| 187 | +{ |
| 188 | + "not": {} |
| 189 | +} |
| 190 | +]]> |
| 191 | + </artwork> |
| 192 | + </figure> |
169 | 193 | </section>
|
170 | 194 |
|
171 |
| - <section title="Validation of primitive types and child values"> |
172 |
| - <t> |
173 |
| - Two of the primitive types, array and object, allow for child values. The validation of |
174 |
| - the primitive type is considered separately from the validation of child instances. |
175 |
| - </t> |
176 |
| - <t> |
177 |
| - For arrays, primitive type validation consists of validating restrictions on length. |
178 |
| - </t> |
| 195 | + <section title="Keyword independence"> |
179 | 196 | <t>
|
180 |
| - For objects, primitive type validation consists of validating restrictions on the presence |
181 |
| - or absence of property names. |
| 197 | + Validation keywords typically operate independently, without |
| 198 | + affecting each other's outcomes. |
182 | 199 | </t>
|
183 |
| - </section> |
184 |
| - |
185 |
| - <section title="Missing keywords"> |
186 | 200 | <t>
|
187 |
| - Validation keywords that are missing never restrict validation. |
188 |
| - In some cases, this no-op behavior is identical to a keyword that exists with certain values, |
189 |
| - and these values are noted where known. |
| 201 | + For schema author convenience, there are some exceptions: |
| 202 | + <list> |
| 203 | + <t>"additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"</t> |
| 204 | + <t>"additionalItems", whose behavior is defined in terms of "items"</t> |
| 205 | + <t>"minimum" and "maximum", whose behaviors are modified by "exclusiveMinimum" and "exclusiveMaximum", respectively</t> |
| 206 | + </list> |
190 | 207 | </t>
|
191 | 208 | </section>
|
192 | 209 |
|
193 |
| - <section title="Linearity"> |
194 |
| - <!-- I call this "linear" in the same manner e.g. waves are linear, they don't interact with each other --> |
| 210 | + <section title="Keywords and instance primitive types"> |
195 | 211 | <t>
|
196 |
| - Validation keywords typically operate independent of each other, without affecting each other. |
| 212 | + Most validation keywords only limit the range of values within a certain primitive type. |
| 213 | + When the primitive type of the instance is not of the type targeted by the keyword, the |
| 214 | + validation succeeds. |
197 | 215 | </t>
|
198 | 216 | <t>
|
199 |
| - For author convienence, there are some exceptions: |
200 |
| - <list> |
201 |
| - <t>"additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"; and</t> |
202 |
| - <t>"additionalItems", whose behavior is defined in terms of "items"</t> |
203 |
| - </list> |
| 217 | + For example, the "maxLength" keyword will only restrict certain strings (that are too long) from being valid. |
| 218 | + If the instance is a number, boolean, null, array, or object, the keyword passes validation. |
204 | 219 | </t>
|
205 | 220 | </section>
|
206 |
| - |
207 | 221 | </section>
|
208 | 222 |
|
209 | 223 | <section title="Validation keywords">
|
|
505 | 519 | </t>
|
506 | 520 | <t>
|
507 | 521 | For all such properties, child validation succeeds if the child instance
|
508 |
| - validates agains the "additionalProperties" schema. |
| 522 | + validates against the "additionalProperties" schema. |
509 | 523 | </t>
|
510 | 524 | </section>
|
511 | 525 |
|
|
663 | 677 | <t>
|
664 | 678 | Both of these keywords can be used to decorate a user interface with
|
665 | 679 | information about the data produced by this user interface. A title will
|
666 |
| - preferrably be short, whereas a description will provide explanation about |
| 680 | + preferably be short, whereas a description will provide explanation about |
667 | 681 | the purpose of the instance described by this schema.
|
668 | 682 | </t>
|
669 | 683 | <t>
|
|
812 | 826 |
|
813 | 827 | <section title="Security considerations">
|
814 | 828 | <t>
|
815 |
| - JSON Schema validation defines a vocabulary for JSON Schema core and conserns all the security considerations listed there. |
| 829 | + JSON Schema validation defines a vocabulary for JSON Schema core and concerns all the security considerations listed there. |
816 | 830 | </t>
|
817 | 831 | <t>
|
818 | 832 | JSON Schema validation allows the use of Regular Expressions, which have numerous different (often incompatible) implementations.
|
819 |
| - Some implementations allow the embedding of arbritrary code, which is outside the scope of JSON Schema and MUST NOT be permitted. |
| 833 | + Some implementations allow the embedding of arbitrary code, which is outside the scope of JSON Schema and MUST NOT be permitted. |
820 | 834 | Regular expressions can often also be crafted to be extremely expensive to compute (with so-called "catastrophic backtracking"),
|
821 | 835 | resulting in a denial-of-service attack.
|
822 | 836 | </t>
|
|
0 commit comments