|
703 | 703 | an alternate implementation producing the same behavior is available. |
704 | 704 | Keywords of this sort SHOULD describe reasonable alternate approaches |
705 | 705 | when appropriate. This approach is demonstrated by the |
706 | | - "<xref target="additionalItems" format="title"/>" and |
| 706 | + "<xref target="items" format="title"/>" and |
707 | 707 | "<xref target="additionalProperties" format="title"/>" keywords in this |
708 | 708 | document. |
709 | 709 | </t> |
|
931 | 931 | { |
932 | 932 | "title": "Feature list", |
933 | 933 | "type": "array", |
934 | | - "items": [ |
| 934 | + "prefixItems": [ |
935 | 935 | { |
936 | 936 | "title": "Feature A", |
937 | 937 | "properties": { |
|
2143 | 2143 | "additionalProperties" and itself |
2144 | 2144 | </t> |
2145 | 2145 | <t> |
2146 | | - "additionalItems", whose behavior is defined in terms of "items" |
| 2146 | + "items", whose behavior is defined in terms of "prefixItems" |
2147 | 2147 | </t> |
2148 | 2148 | <t> |
2149 | 2149 | "unevaluatedItems", whose behavior is defined in terms of annotations |
2150 | | - from "items", "additionalItems" and itself |
| 2150 | + from "prefixItems", "items", "contains", and itself |
2151 | 2151 | </t> |
2152 | 2152 | </list> |
2153 | 2153 | </t> |
|
2326 | 2326 | properties and array items, and combining their results. |
2327 | 2327 | </t> |
2328 | 2328 | <section title="Keywords for Applying Subschemas to Arrays"> |
2329 | | - <section title="items"> |
| 2329 | + <section title="prefixItems"> |
2330 | 2330 | <t> |
2331 | | - The value of "items" MUST be either a valid JSON Schema or |
2332 | | - an array of valid JSON Schemas. |
| 2331 | + The value of "prefixItems" MUST be an array of valid JSON Schemas. |
2333 | 2332 | </t> |
2334 | 2333 | <t> |
2335 | | - If "items" is a schema, validation succeeds if all elements |
2336 | | - in the array successfully validate against that schema. |
2337 | | - </t> |
2338 | | - <t> |
2339 | | - If "items" is an array of schemas, validation succeeds if |
2340 | | - each element of the instance validates against the schema at the |
2341 | | - same position, if any. |
| 2334 | + Validation succeeds if each element of the instance validates |
| 2335 | + against the schema at the same position, if any. This keyword |
| 2336 | + does not constrain the length of the array. If the array is longer |
| 2337 | + than this keyword's value, this keyword validates only the |
| 2338 | + prefix of matching length. |
2342 | 2339 | </t> |
2343 | 2340 | <t> |
2344 | 2341 | This keyword produces an annotation value which is the largest |
2345 | 2342 | index to which this keyword applied a subschema. The value |
2346 | 2343 | MAY be a boolean true if a subschema was applied to every |
2347 | | - index of the instance, such as when "items" is a schema. |
2348 | | - </t> |
2349 | | - <t> |
2350 | | - Annotation results for "items" keywords from multiple |
2351 | | - schemas applied to the same instance location are combined |
2352 | | - by setting the combined result to true if any of the values |
2353 | | - are true, and otherwise retaining the largest numerical value. |
| 2344 | + index of the instance, such as is produced by the "items" keyword. |
| 2345 | + This annotation affects the behavior of "items" and "unevaluatedItems". |
2354 | 2346 | </t> |
2355 | 2347 | <t> |
2356 | 2348 | Omitting this keyword has the same assertion behavior as |
2357 | | - an empty schema. |
| 2349 | + an empty array. |
2358 | 2350 | </t> |
2359 | 2351 | </section> |
2360 | 2352 |
|
2361 | | - <section title="additionalItems" anchor="additionalItems"> |
| 2353 | + <section title="items" anchor="items"> |
2362 | 2354 | <t> |
2363 | | - The value of "additionalItems" MUST be a valid JSON Schema. |
| 2355 | + The value of "items" MUST be a valid JSON Schema. |
2364 | 2356 | </t> |
2365 | 2357 | <t> |
2366 | | - The behavior of this keyword depends on the presence and |
2367 | | - annotation result of "items" within the same schema object. |
2368 | | - If "items" is present, and its annotation result is a number, |
2369 | | - validation succeeds if every instance element at an index |
2370 | | - greater than that number validates against "additionalItems". |
2371 | | - </t> |
2372 | | - <t> |
2373 | | - Otherwise, if "items" is absent or its annotation result |
2374 | | - is the boolean true, "additionalItems" MUST be ignored. |
| 2358 | + This keyword applies its subschema to all instance elements |
| 2359 | + at indexes greater than the length of the "prefixItems" array |
| 2360 | + in the same schema object, as reported by the annotation result |
| 2361 | + of that "prefixItems" keyword. If no such annotation |
| 2362 | + result exists, "items" applies its subschema to all instance |
| 2363 | + array elements. |
| 2364 | + <cref> |
| 2365 | + Note that the behavior of "items" without "prefixItems" is |
| 2366 | + identical to that of the schema form of "items" in prior drafts. |
| 2367 | + When "prefixItems" is present, the behavior of "items" is |
| 2368 | + identical to the former "additionalItems" keyword. |
| 2369 | + </cref> |
2375 | 2370 | </t> |
2376 | 2371 | <t> |
2377 | | - If the "additionalItems" subschema is applied to any |
| 2372 | + If the "items" subschema is applied to any |
2378 | 2373 | positions within the instance array, it produces an |
2379 | | - annotation result of boolean true, analogous to the |
2380 | | - single schema behavior of "items". If any "additionalItems" |
2381 | | - keyword from any subschema applied to the same instance |
2382 | | - location produces an annotation value of true, then |
2383 | | - the combined result from these keywords is also true. |
| 2374 | + annotation result of boolean true, indicating that all remaining array |
| 2375 | + elements have been evaluated against this keyword's subschema. |
2384 | 2376 | </t> |
2385 | 2377 | <t> |
2386 | 2378 | Omitting this keyword has the same assertion behavior as |
|
2389 | 2381 | <t> |
2390 | 2382 | Implementations MAY choose to implement or optimize this keyword |
2391 | 2383 | in another way that produces the same effect, such as by directly |
2392 | | - checking for the presence and size of an "items" array. |
| 2384 | + checking for the presence and size of a "prefixItems" array. |
2393 | 2385 | Implementations that do not support annotation collection MUST do so. |
2394 | 2386 | </t> |
2395 | 2387 | </section> |
|
2401 | 2393 | <t> |
2402 | 2394 | The behavior of this keyword depends on the annotation results of |
2403 | 2395 | adjacent keywords that apply to the instance location being validated. |
2404 | | - Specifically, the annotations from "items" and "additionalItems", |
| 2396 | + Specifically, the annotations from "prefixItems", "items", and "contains", |
2405 | 2397 | which can come from those keywords when they are adjacent to the |
2406 | 2398 | "unevaluatedItems" keyword. Those two annotations, as well as |
2407 | 2399 | "unevaluatedItems", can also result from any and all adjacent |
|
2410 | 2402 | defined in this document. |
2411 | 2403 | </t> |
2412 | 2404 | <t> |
2413 | | - If an "items" annotation is present, and its annotation result |
2414 | | - is a number, and no "additionalItems" or "unevaluatedItems" |
2415 | | - annotation is present, then validation succeeds if every instance |
2416 | | - element at an index greater than the "items" annotation validates |
2417 | | - against "unevaluatedItems". |
| 2405 | + If no relevant annotations are present, the "unevaluatedItems" |
| 2406 | + subschema MUST be applied to all locations in the array. |
| 2407 | + If a boolean true value is present from any of the relevant annotations, |
| 2408 | + "unevaluatedItems" MUST be ignored. Otherwise, the subschema |
| 2409 | + MUST be applied to any index greater than the largest annotation |
| 2410 | + value for "prefixItems", which does not appear in any annotation |
| 2411 | + value for "contains". |
2418 | 2412 | </t> |
2419 | 2413 | <t> |
2420 | | - Otherwise, if any "items", "additionalItems", or "unevaluatedItems" |
2421 | | - annotations are present with a value of boolean true, then |
2422 | | - "unevaluatedItems" MUST be ignored. However, if none of these |
2423 | | - annotations are present, "unevaluatedItems" MUST be applied to |
2424 | | - all locations in the array. |
2425 | | - </t> |
2426 | | - <t> |
2427 | | - This means that "items", "additionalItems", and all in-place applicators |
2428 | | - MUST be evaluated before this keyword can be evaluated. Authors of |
2429 | | - extension keywords MUST NOT define an in-place applicator that would need |
2430 | | - to be evaluated before this keyword. |
| 2414 | + This means that "prefixItems", "items", "contains", and all in-place |
| 2415 | + applicators MUST be evaluated before this keyword can be evaluated. |
| 2416 | + Authors of extension keywords MUST NOT define an in-place applicator |
| 2417 | + that would need to be evaluated before this keyword. |
2431 | 2418 | </t> |
2432 | 2419 | <t> |
2433 | 2420 | If the "unevaluatedItems" subschema is applied to any |
2434 | 2421 | positions within the instance array, it produces an |
2435 | 2422 | annotation result of boolean true, analogous to the |
2436 | | - single schema behavior of "items". If any "unevaluatedItems" |
2437 | | - keyword from any subschema applied to the same instance |
2438 | | - location produces an annotation value of true, then |
2439 | | - the combined result from these keywords is also true. |
| 2423 | + behavior of "items". |
2440 | 2424 | </t> |
2441 | 2425 | <t> |
2442 | 2426 | Omitting this keyword has the same assertion behavior as |
|
2459 | 2443 | array element even after the first match has been found. This |
2460 | 2444 | is to ensure that all possible annotations are collected. |
2461 | 2445 | </t> |
| 2446 | + <t> |
| 2447 | + This keyword produces an annotation value which is an array of |
| 2448 | + the indexes to which this keyword validates successfully when applying |
| 2449 | + its subschema, in ascending order. The value MAY be a boolean true if the |
| 2450 | + subschema validated successfully when applied to every index of the instance. |
| 2451 | + </t> |
2462 | 2452 | </section> |
2463 | 2453 | </section> |
2464 | 2454 |
|
@@ -3800,9 +3790,9 @@ https://example.com/schemas/common#/$defs/count/minimum |
3800 | 3790 | <t hangText="draft-handrews-json-schema-03"> |
3801 | 3791 | <list style="symbols"> |
3802 | 3792 | <t></t> |
3803 | | - <t></t> |
3804 | | - <t></t> |
3805 | | - <t></t> |
| 3793 | + <t>Array-value "items" functionality is now "prefixItems"</t> |
| 3794 | + <t>"items" subsumes the old function of "additionalItems"</t> |
| 3795 | + <t>"contains" and "unevaluatedItems" interactions now specified</t> |
3806 | 3796 | <t></t> |
3807 | 3797 | <t></t> |
3808 | 3798 | <t></t> |
|
0 commit comments