|
159 | 159 |
|
160 | 160 | <section title="General validation considerations">
|
161 | 161 |
|
162 | | - <section title="Keywords and instance primitive types"> |
163 | | - <t> |
164 | | - Most validation keywords only constrain values within a certain primitive type. |
165 | | - When the type of the instance is not of the type targeted by the keyword, the |
166 | | - validation succeeds. |
167 | | - </t> |
168 | | - <t> |
169 | | - For example, the "maxLength" keyword will only restrict certain strings (that are too long) from being valid. |
170 | | - If the instance is a number, boolean, null, array, or object, the keyword passes validation. |
171 | | - </t> |
172 | | - </section> |
173 | | - |
174 | | - <section title="Validation of primitive types and child values"> |
175 | | - <t> |
176 | | - Two of the primitive types, array and object, allow for child values. |
177 | | - The validation of the primitive type is considered separately from |
178 | | - the validation of child instances. |
179 | | - </t> |
180 | | - <t> |
181 | | - Note that while array elements are validated by at most one |
182 | | - subschema, object property values may be validated by several |
183 | | - subschemas from "properties" and "patternProperties". |
184 | | - </t> |
185 | | - </section> |
186 | | - |
187 | 162 | <section title="Constraints and missing keywords">
|
188 | 163 | <t>
|
189 | 164 | Each JSON Schema validation keyword adds constraints that
|
|
227 | 202 | </t>
|
228 | 203 |
|
229 | 204 | <section title="Validation keywords for numeric instances (number and integer)">
|
| 205 | + <t> |
| 206 | + These keywords apply only to numbers (including integers). |
| 207 | + Validation of other types against these keywords always succeeds. |
| 208 | + </t> |
| 209 | + |
230 | 210 | <section title="multipleOf">
|
231 | 211 | <t>
|
232 | 212 | The value of "multipleOf" MUST be a number, strictly greater than 0.
|
|
274 | 254 | </section>
|
275 | 255 |
|
276 | 256 | <section title="Validation keywords for strings">
|
| 257 | + <t> |
| 258 | + These keywords apply only to strings. Validation |
| 259 | + of other types against these keywords always succeeds. |
| 260 | + </t> |
277 | 261 |
|
278 | 262 | <section title="maxLength">
|
279 | 263 | <t>
|
|
320 | 304 | </section>
|
321 | 305 | </section>
|
322 | 306 |
|
323 | | - <section title="Validation keywords for arrays as primitive types"> |
| 307 | + <section title="Validation keywords for arrays"> |
324 | 308 | <t>
|
325 | | - These keywords validate characteristics of arrays independent of their contents. |
| 309 | + These keywords validate characteristics of arrays as a whole, |
| 310 | + rather than validating specific array elements. |
| 311 | + Validation of other instance types against these keywords always succeeds. |
326 | 312 | </t>
|
327 | 313 |
|
328 | 314 | <section title="maxItems">
|
|
347 | 333 | Omitting this keyword has the same behavior as a value of 0.
|
348 | 334 | </t>
|
349 | 335 | </section>
|
350 | | - </section> |
351 | 336 |
|
352 | | - <section title="Validation keywords for array contents"> |
353 | | - <t> |
354 | | - These keywords validate conditions, specifically existence and uniqueness, across all array contents. |
355 | | - </t> |
356 | | - <section title="contains"> |
357 | | - <t> |
358 | | - The value of this keyword MUST be an object. This object MUST be |
359 | | - a valid JSON Schema. |
360 | | - </t> |
361 | | - <t> |
362 | | - An array instance is valid against "contains" if at least one of |
363 | | - its elements is valid against the given schema. |
364 | | - </t> |
365 | | - </section> |
366 | 337 | <section title="uniqueItems">
|
367 | 338 | <t>
|
368 | 339 | The value of this keyword MUST be a boolean.
|
|
376 | 347 | Omitting this keyword has the same behavior as a value of false.
|
377 | 348 | </t>
|
378 | 349 | </section>
|
| 350 | + |
| 351 | + <section title="contains"> |
| 352 | + <t> |
| 353 | + The value of this keyword MUST be an object. This object MUST be |
| 354 | + a valid JSON Schema. |
| 355 | + </t> |
| 356 | + <t> |
| 357 | + An array instance is valid against "contains" if at least one of |
| 358 | + its elements is valid against the given schema. |
| 359 | + </t> |
| 360 | + </section> |
379 | 361 | </section>
|
380 | 362 |
|
381 | 363 | <section title="Validating array elements with subschemas">
|
382 | 364 | <t>
|
383 | 365 | These keywords determine which subschemas apply to each element of an array.
|
| 366 | + Validation of other instance types against these keywords always succeeds. |
384 | 367 | </t>
|
385 | 368 | <section title="items">
|
386 | 369 | <t>
|
387 | 370 | The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas.
|
388 | 371 | </t>
|
389 | 372 | <t>
|
390 | | - This keyword determines how child instances validate for arrays, |
391 | | - and does not directly validate the immediate instance itself. |
392 | | - </t> |
393 | | - <t> |
394 | | - If "items" is a schema, child validation succeeds if all elements |
| 373 | + If "items" is a schema, validation succeeds if all elements |
395 | 374 | in the array successfully validate against that schema.
|
396 | 375 | </t>
|
397 | 376 | <t>
|
398 | | - If "items" is an array of schemas, child validation succeeds if |
| 377 | + If "items" is an array of schemas, validation succeeds if |
399 | 378 | each element of the instance validates against the schema at the
|
400 | 379 | same position, if any.
|
401 | 380 | </t>
|
|
409 | 388 | The value of "additionalItems" MUST be a valid JSON Schema.
|
410 | 389 | </t>
|
411 | 390 | <t>
|
412 | | - This keyword determines how child instances validate for arrays, |
413 | | - and does not directly validate the immediate instance itself. |
414 | | - </t> |
415 | | - <t> |
416 | | - If "items" is an array of schemas, child validation succeeds |
417 | | - if every instance element at a position greater than the size |
418 | | - of "items" validates against "additionalItems". |
| 391 | + If "items" is an array of schemas, validation against |
| 392 | + "additionalItems" succeeds if every instance element at |
| 393 | + a position greater than the size of "items" validates |
| 394 | + against the "additionalItems" schema. |
419 | 395 | </t>
|
420 | 396 | <t>
|
421 | 397 | Otherwise, "additionalItems" MUST be ignored, as the "items"
|
422 | | - schema (possibly the default value of an empty schema) is |
423 | | - applied to all elements. |
| 398 | + schema is applied to all elements. Since omitting "items" |
| 399 | + has the same behavior as an empty "items" schema, "additonalItems" |
| 400 | + MUST be ignored if "items" is omitted. |
424 | 401 | </t>
|
425 | 402 | <t>
|
426 | 403 | Omitting this keyword has the same behavior as an empty schema.
|
427 | 404 | </t>
|
428 | 405 | </section>
|
429 | 406 | </section>
|
430 | 407 |
|
431 | | - <section title="Validation keywords for objects as primitive types"> |
| 408 | + <section title="Validation keywords for objects"> |
432 | 409 | <t>
|
433 | 410 | These keywords validate characteristics of objects independent of the values of their properties.
|
| 411 | + Validation of other instance types against these keywords always succeeds. |
434 | 412 | </t>
|
435 | 413 |
|
436 | 414 | <section title="maxProperties">
|
|
490 | 468 | <section title="Validating object properties with subschemas">
|
491 | 469 | <t>
|
492 | 470 | These keywords determine which subschemas apply to each property of an object.
|
| 471 | + Validation of other instance types against these keywords always succeeds. |
493 | 472 | </t>
|
494 | 473 |
|
495 | 474 | <section title="properties">
|
|
498 | 477 | Each value of this object MUST be a valid JSON Schema.
|
499 | 478 | </t>
|
500 | 479 | <t>
|
501 | | - This keyword determines how child instances validate for objects, |
502 | | - and does not directly validate the immediate instance itself. |
503 | | - </t> |
504 | | - <t> |
505 | | - Child validation succeeds if, for each name that appears in both |
| 480 | + Validation succeeds if, for each name that appears in both |
506 | 481 | the instance and as a name within this keyword's value, the child
|
507 | 482 | instance for that name successfully validates against the
|
508 | 483 | corresponding schema.
|
|
520 | 495 | MUST be a valid JSON Schema.
|
521 | 496 | </t>
|
522 | 497 | <t>
|
523 | | - This keyword determines how child instances validate for objects, |
524 | | - and does not directly validate the immediate instance itself. |
525 | | - Validation of the primitive instance type against this keyword |
526 | | - always succeeds. |
527 | | - </t> |
528 | | - <t> |
529 | | - Child validation succeeds if, for each instance name that matches any |
| 498 | + Validation succeeds if, for each instance property name that matches any |
530 | 499 | regular expressions that appear as a property name in this keyword's value,
|
531 | 500 | the child instance for that name successfully validates against each
|
532 | 501 | schema that corresponds to a matching regular expression.
|
|
541 | 510 | The value of "additionalProperties" MUST be a valid JSON Schema.
|
542 | 511 | </t>
|
543 | 512 | <t>
|
544 | | - This keyword determines how child instances validate for objects, |
545 | | - and does not directly validate the immediate instance itself. |
546 | | - </t> |
547 | | - <t> |
548 | | - Child validation with "additionalProperties" applies only to the child |
549 | | - values of instance names that do not match any names in "properties", |
550 | | - and do not match any regular expression in "patternProperties". |
551 | | - </t> |
552 | | - <t> |
553 | | - For all such properties, child validation succeeds if the child instance |
554 | | - validates against the "additionalProperties" schema. |
| 513 | + Validation succeeds if, for each instance property name |
| 514 | + that does not match any names in "properties", |
| 515 | + and does not match any regular expression in "patternProperties", |
| 516 | + the child instance for that name successfully validates against |
| 517 | + the "additionalProperties" schema. |
555 | 518 | </t>
|
556 | 519 | <t>
|
557 | 520 | Omitting this keyword has the same behavior as an empty schema.
|
|
564 | 527 | <t>
|
565 | 528 | This keyword specifies rules that are evaluated if the instance is an object and
|
566 | 529 | contains a certain property.
|
| 530 | + Validation against instances of types other than object |
| 531 | + always succeeds. |
567 | 532 | </t>
|
568 | 533 | <t>
|
569 | 534 | This keyword's value MUST be an object. Each property specifies a dependency.
|
|
0 commit comments