Disallow - sgpinkus/json-schema GitHub Wiki

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


NOTE: This Draft 03 feature was intentionally removed in Draft 04. The functionality is now addressed with the not keyword.


Description

An instance is valid against this keyword if an only if:

  • its type is NOT one of the primitive types specified by this keyword, if any; or
  • it does not validate against any of the schemas specified by this keyword, if any.

In this sense, it is the exact opposite of the type keyword.

Valid values

See type.

Example

Given this schema:

{
    "disallow": [ "boolean", "number", { "type": "string", "format": "email" } ]
}

the following instances are valid:

  • null;
  • "@foo";
  • { "a": "b" };

the following instances are invalid:

  • 4 (remember: number includes integer);
  • "foo" (emails are not required to have a domain part as per the RFC);
  • true.

Concerns

  • How is this different from the existing not?
  • The syntax "disallow": [ "boolean", ... ] is deviant from the existing {"type": "boolean" }
⚠️ **GitHub.com Fallback** ⚠️