|
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">
|
|
0 commit comments