|
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": {
|
|
2141 | 2141 | "additionalProperties" and itself
|
2142 | 2142 | </t>
|
2143 | 2143 | <t>
|
2144 |
| - "additionalItems", whose behavior is defined in terms of "items" |
| 2144 | + "items", whose behavior is defined in terms of "prefixItems" |
2145 | 2145 | </t>
|
2146 | 2146 | <t>
|
2147 | 2147 | "unevaluatedItems", whose behavior is defined in terms of annotations
|
2148 |
| - from "items", "additionalItems" and itself |
| 2148 | + from "prefixItems", "items", "contains", and itself |
2149 | 2149 | </t>
|
2150 | 2150 | </list>
|
2151 | 2151 | </t>
|
|
2324 | 2324 | properties and array items, and combining their results.
|
2325 | 2325 | </t>
|
2326 | 2326 | <section title="Keywords for Applying Subschemas to Arrays">
|
2327 |
| - <section title="items"> |
| 2327 | + <section title="prefixItems"> |
2328 | 2328 | <t>
|
2329 |
| - The value of "items" MUST be either a valid JSON Schema or |
2330 |
| - an array of valid JSON Schemas. |
| 2329 | + The value of "prefixItems" MUST be an array of valid JSON Schemas. |
2331 | 2330 | </t>
|
2332 | 2331 | <t>
|
2333 |
| - If "items" is a schema, validation succeeds if all elements |
2334 |
| - in the array successfully validate against that schema. |
2335 |
| - </t> |
2336 |
| - <t> |
2337 |
| - If "items" is an array of schemas, validation succeeds if |
2338 |
| - each element of the instance validates against the schema at the |
2339 |
| - same position, if any. |
| 2332 | + Validation succeeds if each element of the instance validates |
| 2333 | + against the schema at the same position, if any. |
2340 | 2334 | </t>
|
2341 | 2335 | <t>
|
2342 | 2336 | This keyword produces an annotation value which is the largest
|
2343 | 2337 | index to which this keyword applied a subschema. The value
|
2344 | 2338 | MAY be a boolean true if a subschema was applied to every
|
2345 |
| - index of the instance, such as when "items" is a schema. |
2346 |
| - </t> |
2347 |
| - <t> |
2348 |
| - Annotation results for "items" keywords from multiple |
2349 |
| - schemas applied to the same instance location are combined |
2350 |
| - by setting the combined result to true if any of the values |
2351 |
| - are true, and otherwise retaining the largest numerical value. |
| 2339 | + index of the instance, such as is produced by the "items" keyword. |
2352 | 2340 | </t>
|
2353 | 2341 | <t>
|
2354 | 2342 | Omitting this keyword has the same assertion behavior as
|
2355 |
| - an empty schema. |
| 2343 | + an empty array. |
2356 | 2344 | </t>
|
2357 | 2345 | </section>
|
2358 | 2346 |
|
2359 |
| - <section title="additionalItems" anchor="additionalItems"> |
2360 |
| - <t> |
2361 |
| - The value of "additionalItems" MUST be a valid JSON Schema. |
2362 |
| - </t> |
| 2347 | + <section title="items" anchor="items"> |
2363 | 2348 | <t>
|
2364 |
| - The behavior of this keyword depends on the presence and |
2365 |
| - annotation result of "items" within the same schema object. |
2366 |
| - If "items" is present, and its annotation result is a number, |
2367 |
| - validation succeeds if every instance element at an index |
2368 |
| - greater than that number validates against "additionalItems". |
| 2349 | + The value of "items" MUST be a valid JSON Schema. |
2369 | 2350 | </t>
|
2370 | 2351 | <t>
|
2371 |
| - Otherwise, if "items" is absent or its annotation result |
2372 |
| - is the boolean true, "additionalItems" MUST be ignored. |
| 2352 | + This keyword applies its subschema to all instance elements |
| 2353 | + at indexes greater than the length of the "prefixItems" array |
| 2354 | + in the same schema object, as reported by the annotation result |
| 2355 | + of that "prefixItems" keyword. If no such annotation |
| 2356 | + result exists, "items" applies its subschema to all instance |
| 2357 | + array elements. |
| 2358 | + <cref> |
| 2359 | + Note that the behavior of "items" without "prefixItems" is |
| 2360 | + identical to that of the schema form of "items" in prior drafts. |
| 2361 | + When "prefixItems" is present, the behavior of "items" is |
| 2362 | + identical to the former "additionalItems" keyword. |
| 2363 | + </cref> |
2373 | 2364 | </t>
|
2374 | 2365 | <t>
|
2375 |
| - If the "additionalItems" subschema is applied to any |
| 2366 | + If the "items" subschema is applied to any |
2376 | 2367 | positions within the instance array, it produces an
|
2377 |
| - annotation result of boolean true, analogous to the |
2378 |
| - single schema behavior of "items". If any "additionalItems" |
2379 |
| - keyword from any subschema applied to the same instance |
2380 |
| - location produces an annotation value of true, then |
2381 |
| - the combined result from these keywords is also true. |
| 2368 | + annotation result of boolean true, indicating that all remaining array |
| 2369 | + elements have been evaluated against this keyword's subschema. |
2382 | 2370 | </t>
|
2383 | 2371 | <t>
|
2384 | 2372 | Omitting this keyword has the same assertion behavior as
|
|
2387 | 2375 | <t>
|
2388 | 2376 | Implementations MAY choose to implement or optimize this keyword
|
2389 | 2377 | in another way that produces the same effect, such as by directly
|
2390 |
| - checking for the presence and size of an "items" array. |
| 2378 | + checking for the presence and size of a "prefixItems" array. |
2391 | 2379 | Implementations that do not support annotation collection MUST do so.
|
2392 | 2380 | </t>
|
2393 | 2381 | </section>
|
|
2399 | 2387 | <t>
|
2400 | 2388 | The behavior of this keyword depends on the annotation results of
|
2401 | 2389 | adjacent keywords that apply to the instance location being validated.
|
2402 |
| - Specifically, the annotations from "items" and "additionalItems", |
| 2390 | + Specifically, the annotations from "prefixItems", "items", and "contains", |
2403 | 2391 | which can come from those keywords when they are adjacent to the
|
2404 | 2392 | "unevaluatedItems" keyword. Those two annotations, as well as
|
2405 | 2393 | "unevaluatedItems", can also result from any and all adjacent
|
|
2408 | 2396 | defined in this document.
|
2409 | 2397 | </t>
|
2410 | 2398 | <t>
|
2411 |
| - If an "items" annotation is present, and its annotation result |
2412 |
| - is a number, and no "additionalItems" or "unevaluatedItems" |
2413 |
| - annotation is present, then validation succeeds if every instance |
2414 |
| - element at an index greater than the "items" annotation validates |
2415 |
| - against "unevaluatedItems". |
| 2399 | + If no relevant annotations are present, the "unevaluatedItems" |
| 2400 | + subschema MUST be applied to all locations in the array. |
| 2401 | + If a boolean true value is present from any of the relevant annotations, |
| 2402 | + "unevaluatedItems" MUST be ignored. Otherwise, the subschema |
| 2403 | + MUST be applied to any index greater than the largest annotation |
| 2404 | + value for "prefixItems", which does not appear in any annotation |
| 2405 | + value for "contains". |
2416 | 2406 | </t>
|
2417 | 2407 | <t>
|
2418 |
| - Otherwise, if any "items", "additionalItems", or "unevaluatedItems" |
2419 |
| - annotations are present with a value of boolean true, then |
2420 |
| - "unevaluatedItems" MUST be ignored. However, if none of these |
2421 |
| - annotations are present, "unevaluatedItems" MUST be applied to |
2422 |
| - all locations in the array. |
2423 |
| - </t> |
2424 |
| - <t> |
2425 |
| - This means that "items", "additionalItems", and all in-place applicators |
2426 |
| - MUST be evaluated before this keyword can be evaluated. Authors of |
2427 |
| - extension keywords MUST NOT define an in-place applicator that would need |
2428 |
| - to be evaluated before this keyword. |
| 2408 | + This means that "prefixItems", "items", "contains", and all in-place |
| 2409 | + applicators MUST be evaluated before this keyword can be evaluated. |
| 2410 | + Authors of extension keywords MUST NOT define an in-place applicator |
| 2411 | + that would need to be evaluated before this keyword. |
2429 | 2412 | </t>
|
2430 | 2413 | <t>
|
2431 | 2414 | If the "unevaluatedItems" subschema is applied to any
|
2432 | 2415 | positions within the instance array, it produces an
|
2433 | 2416 | annotation result of boolean true, analogous to the
|
2434 |
| - single schema behavior of "items". If any "unevaluatedItems" |
2435 |
| - keyword from any subschema applied to the same instance |
2436 |
| - location produces an annotation value of true, then |
2437 |
| - the combined result from these keywords is also true. |
| 2417 | + behavior of "items". |
2438 | 2418 | </t>
|
2439 | 2419 | <t>
|
2440 | 2420 | Omitting this keyword has the same assertion behavior as
|
|
2457 | 2437 | array element even after the first match has been found. This
|
2458 | 2438 | is to ensure that all possible annotations are collected.
|
2459 | 2439 | </t>
|
| 2440 | + <t> |
| 2441 | + This keyword produces an annotation value which is an array of |
| 2442 | + the indexes to which this keyword successfully applied its subschema, |
| 2443 | + in ascending order. The value MAY be a boolean true if the subschema |
| 2444 | + was successfully applied to every index of the instance. |
| 2445 | + </t> |
2460 | 2446 | </section>
|
2461 | 2447 | </section>
|
2462 | 2448 |
|
|
0 commit comments