Format - sgpinkus/json-schema GitHub Wiki

THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.



Description

The format keyword value is a string which is called a format attribute. This format attribute only applies to a certain set of primitive types as defined by JSON Schema (see here).

If the type of the instance to validate is not within this set, then validation succeeds. Otherwise, the instance MUST be valid against that format attribute.

The list of format attributes defined by the draft can be found here.

Note

Implementations MAY choose to, but are not required to, validate instances against this keyword.

Implementations MAY choose to add additional attributes.

Valid values

The value for this keyword MUST be a string.

Example

Given this schema:

{
    "format": "host-name"
}

the following instances are valid:

  • foo;
  • json-schema.org;
  • my.host;

the following instances are invalid:

  • mémé;
  • -x.com.
⚠️ **GitHub.com Fallback** ⚠️