type - sgpinkus/json-schema GitHub Wiki

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



Description

An instance is valid with regards to this keyword if and only if:

  • its type is one of the primitive types specified by this keyword, if any (see here for a list); or
  • it is valid against at least one of the schemas specified by this keyword, if any.

Valid values

The value of this keyword MUST be either a string or an array.

If it is a string, then its value MUST be one of the seven primitive types defined by the draft (see above); in addition, value any denotes the whole set of primitive types. Note that number includes integer.

If it is an array, then this array MUST have at least one element; elements of the array MUST be either strings or objects; if the element is a string, it MUST comply to the rules described in the previous paragraph; if it is an object, this object MUST be a valid JSON Schema.

Example

Given this schema:

{
    "type": [ "string", "null", { "type": "integer", "minimum": 8 } ]
}

the following instances are valid:

  • "";
  • null;
  • 64;

the following instances are not valid:

  • 1;
  • false;
  • [].
⚠️ **GitHub.com Fallback** ⚠️