|  | 
| 514 | 514 |  <section title="Foreword"> | 
| 515 | 515 |  <t> | 
| 516 | 516 |  Structural validation alone may be insufficient to allow an application to correctly | 
| 517 |  | - utilize certain values. The "format" annotation keyword is defined to allow schema | 
|  | 517 | + utilize certain values. The "format" annotation keyword is defined to allow schema | 
| 518 | 518 |  authors to convey semantic information for a fixed subset of values which are | 
| 519 | 519 |  accurately described by authoritative resources, be they RFCs or other external | 
| 520 | 520 |  specifications. | 
| 521 | 521 |  </t> | 
| 522 | 522 | 
 | 
| 523 |  | - <t> | 
| 524 |  | - Implementations MAY treat "format" as an assertion in addition to an annotation, | 
| 525 |  | - and attempt to validate the value's conformance to the specified semantics. | 
| 526 |  | - See the Implementation Requirements below for details. | 
| 527 |  | - </t> | 
| 528 |  | - | 
| 529 | 523 |  <t> | 
| 530 | 524 |  The value of this keyword is called a format attribute. It MUST be a string. A | 
| 531 | 525 |  format attribute can generally only validate a given set of instance types. If | 
|  | 
| 536 | 530 |  <xref target="json-schema">core JSON Schema.</xref> | 
| 537 | 531 |  <cref> | 
| 538 | 532 |  Note that the "type" keyword in this specification defines an "integer" type | 
| 539 |  | - which is not part of the data model. Therefore a format attribute can be | 
| 540 |  | - limited to numbers, but not specifically to integers. However, a numeric | 
|  | 533 | + which is not part of the data model. Therefore a format attribute can be | 
|  | 534 | + limited to numbers, but not specifically to integers. However, a numeric | 
| 541 | 535 |  format can be used alongside the "type" keyword with a value of "integer", | 
| 542 | 536 |  or could be explicitly defined to always pass if the number is not an integer, | 
| 543 | 537 |  which produces essentially the same behavior as only applying to integers. | 
| 544 | 538 |  </cref> | 
| 545 | 539 |  </t> | 
| 546 | 540 | 
 | 
| 547 | 541 |  <t> | 
| 548 |  | - Meta-schemas that do not use "$vocabulary" SHOULD be considered to | 
| 549 |  | - utilize this vocabulary as if its URI were present with a value of false. | 
| 550 |  | - See the Implementation Requirements below for details. | 
|  | 542 | + The current URI for this vocabulary, known as the Format-Annotation vocabulary, is: | 
|  | 543 | + <https://json-schema.org/draft/2020-11/vocab/format-annotation>. The current | 
|  | 544 | + URI for the corresponding meta-schema is: | 
|  | 545 | + <eref target="https://json-schema.org/draft/2020-11/meta/format-annotation"/>. | 
|  | 546 | + Implementing support for this vocabulary is REQUIRED. | 
| 551 | 547 |  </t> | 
| 552 | 548 |  <t> | 
| 553 |  | - The current URI for this vocabulary, known as the Format vocabulary, is: | 
| 554 |  | - <https://json-schema.org/draft/2020-11/vocab/format>. | 
|  | 549 | + In addition to the Format-Annotation vocabulary, a secondary vocabulary is available | 
|  | 550 | + for custom meta-schemas that defines "format" as an assertion. The URI for the | 
|  | 551 | + Format-Assertion vocabulary, is: | 
|  | 552 | + <https://json-schema.org/draft/2020-11/vocab/format-assertion>. The current | 
|  | 553 | + URI for the corresponding meta-schema is: | 
|  | 554 | + <eref target="https://json-schema.org/draft/2020-11/meta/format-assertion"/>. | 
|  | 555 | + Implementing support for the Format-Assertion vocabulary is OPTIONAL. | 
| 555 | 556 |  </t> | 
| 556 | 557 |  <t> | 
| 557 |  | - The current URI for the corresponding meta-schema is: | 
| 558 |  | - <eref target="https://json-schema.org/draft/2020-11/meta/format"/>. | 
|  | 558 | + Specifying both the Format-Annotation and the Format-Assertion vocabularies is functionally | 
|  | 559 | + equivalent to specifying only the Format-Assertion vocabulary since its requirements | 
|  | 560 | + are a superset of the Format-Annotation vocabulary. | 
| 559 | 561 |  </t> | 
| 560 |  | - | 
| 561 | 562 |  </section> | 
| 562 | 563 | 
 | 
| 563 | 564 |  <section title="Implementation Requirements"> | 
| 564 | 565 |  <t> | 
| 565 |  | - The "format" keyword functions as an annotation, and optionally as an assertion. | 
| 566 |  | - <cref>This is due to the keyword's history, and is not in line with current | 
| 567 |  | - keyword design principles.</cref> In order to manage this ambiguity, the | 
| 568 |  | - "format" keyword is defined in its own separate vocabulary, as noted above. | 
| 569 |  | - The true or false value of the vocabulary declaration governs the implementation | 
| 570 |  | - requirements necessary to process a schema that uses "format", and the | 
| 571 |  | - behaviors on which schema authors can rely. | 
|  | 566 | + The "format" keyword functions as defined by the vocabulary which is referenced. | 
| 572 | 567 |  </t> | 
| 573 | 568 | 
 | 
| 574 |  | - <section title="As an annotation"> | 
|  | 569 | + <section title="Format-Annotation Vocabulary"> | 
| 575 | 570 |  <t> | 
| 576 | 571 |  The value of format MUST be collected as an annotation, if the implementation | 
| 577 |  | - supports annotation collection. This enables application-level validation when | 
|  | 572 | + supports annotation collection. This enables application-level validation when | 
| 578 | 573 |  schema validation is unavailable or inadequate. | 
| 579 | 574 |  </t> | 
| 580 | 575 |  <t> | 
| 581 |  | - This requirement is not affected by the boolean value of the vocabulary | 
| 582 |  | - declaration, nor by the configuration of "format"'s assertion | 
| 583 |  | - behavior described in the next section. | 
|  | 576 | + Implementations MAY still treat "format" as an assertion in addition to an | 
|  | 577 | + annotation and attempt to validate the value's conformance to the specified | 
|  | 578 | + semantics. The implementation MUST provide options to enable and disable such | 
|  | 579 | + evaluation and MUST be disabled by default. Implementations SHOULD document | 
|  | 580 | + their level of support for such validation. | 
| 584 | 581 |  <cref> | 
| 585 |  | - Requiring annotation collection even when the vocabulary is declared with | 
| 586 |  | - a value of false is atypical, but necessary to ensure that the best | 
| 587 |  | - practice of performing application-level validation is possible even when | 
| 588 |  | - assertion evaluation is not implemented. Since "format" has always been | 
| 589 |  | - a part of this specification, requiring implementations to be aware of it | 
| 590 |  | - even with a false vocabulary declaration is deemed to not be a burden. | 
|  | 582 | + Specifying the Format-Annotation vocabulary and enabling validation in an | 
|  | 583 | + implementation should not be viewed as being equivalent to specifying | 
|  | 584 | + the Format-Assertion vocabulary since implementations are not required to | 
|  | 585 | + provide full validation support when the Format-Assertion vocabulary | 
|  | 586 | + is not specified. | 
| 591 | 587 |  </cref> | 
| 592 | 588 |  </t> | 
| 593 |  | - </section> | 
| 594 |  | - | 
| 595 |  | - <section title="As an assertion"> | 
| 596 |  | - <t> | 
| 597 |  | - Regardless of the boolean value of the vocabulary declaration, | 
| 598 |  | - an implementation that can evaluate "format" as an assertion MUST provide | 
| 599 |  | - options to enable and disable such evaluation. The assertion evaluation | 
| 600 |  | - behavior when the option is not explicitly specified depends on | 
| 601 |  | - the vocabulary declaration's boolean value. | 
| 602 |  | - </t> | 
| 603 |  | - | 
| 604 | 589 |  <t> | 
| 605 |  | - When implementing this entire specification, this vocabulary MUST | 
| 606 |  | - be supported with a value of false (but see details below), | 
| 607 |  | - and MAY be supported with a value of true. | 
| 608 |  | - </t> | 
| 609 |  | - | 
| 610 |  | - <t> | 
| 611 |  | - When the vocabulary is declared with a value of false, an implementation: | 
|  | 590 | + When the implementation is configured for assertion behavior, it: | 
| 612 | 591 |  <list> | 
| 613 |  | - <t> | 
| 614 |  | - MUST NOT evaluate "format" as an assertion unless it is explicitly | 
| 615 |  | - configured to do so; | 
| 616 |  | - </t> | 
| 617 | 592 |  <t> | 
| 618 | 593 |  SHOULD provide an implementation-specific best effort validation | 
| 619 | 594 |  for each format attribute defined below; | 
|  | 
| 622 | 597 |  MAY choose to implement validation of any or all format attributes | 
| 623 | 598 |  as a no-op by always producing a validation result of true; | 
| 624 | 599 |  </t> | 
| 625 |  | - <t> | 
| 626 |  | - SHOULD document its level of support for validation. | 
| 627 |  | - </t> | 
| 628 | 600 |  </list> | 
| 629 | 601 |  <cref> | 
| 630 | 602 |  This matches the current reality of implementations, which provide | 
|  | 
| 634 | 606 |  validation in the application, which is the recommended best practice. | 
| 635 | 607 |  </cref> | 
| 636 | 608 |  </t> | 
|  | 609 | + </section> | 
| 637 | 610 | 
 | 
|  | 611 | + <section title="Format-Assertion Vocabulary"> | 
|  | 612 | + <t> | 
|  | 613 | + When the Format-Assertion vocabulary is declared with a value of true, | 
|  | 614 | + implementations MUST provide full validation support for all of the formats | 
|  | 615 | + defined by this specificaion. Implementations that cannot provide full | 
|  | 616 | + validation support MUST refuse to process the schema. | 
|  | 617 | + </t> | 
| 638 | 618 |  <t> | 
| 639 |  | - When the vocabulary is declared with a value of true, an implementation | 
| 640 |  | - that supports this form of the vocabulary: | 
|  | 619 | + An implementation that supports the Format-Assertion vocabulary: | 
| 641 | 620 |  <list> | 
| 642 | 621 |  <t> | 
| 643 |  | - MUST evaluate "format" as an assertion unless it is explicitly | 
| 644 |  | - configured not to do so; | 
|  | 622 | + MUST still collect "format" as an annotation if the implementation | 
|  | 623 | + supports annotation collection; | 
|  | 624 | + </t> | 
|  | 625 | + <t> | 
|  | 626 | + MUST evaluate "format" as an assertion; | 
| 645 | 627 |  </t> | 
| 646 | 628 |  <t> | 
| 647 | 629 |  MUST implement syntactic validation for all format attributes defined | 
|  | 
| 685 | 667 |  <t> | 
| 686 | 668 |  Implementations MAY support custom format attributes. Save for agreement between | 
| 687 | 669 |  parties, schema authors SHALL NOT expect a peer implementation to support such | 
| 688 |  | - custom format attributes. An implementation MUST NOT fail | 
| 689 |  | - validation or cease processing due to an unknown format attribute. | 
| 690 |  | - When treating "format" as an annotation, implementations SHOULD collect both | 
| 691 |  | - known and unknown format attribute values. | 
|  | 670 | + custom format attributes. An implementation MUST NOT fail to collect unknown formats | 
|  | 671 | + as annotations. When the Format-Assertion vocabulary is specified, implementations | 
|  | 672 | + MUST fail upon encountering unknown formats. | 
| 692 | 673 |  </t> | 
| 693 | 674 |  <t> | 
| 694 | 675 |  Vocabularies do not support specifically declaring different value sets for keywords. | 
|  | 
0 commit comments