How to read this page
Schema handling has two phases:
- Parse phase (
FileSchemaLoader): keywords are recognized and mapped toSchemafields. - Validation phase (
ObjectValidator,ArrayValidator,PrimitiveValidator): only some parsed fields are enforced.
A keyword can be accepted at parse time but still not enforced at runtime.
Enforced keywords (runtime)
Type and structure
type(including type arrays like["string", "null"])propertiespatternPropertiesrequiredadditionalProperties(boolean and schema forms)propertyNamesunevaluatedPropertiesitemsprefixItems(2019-09/2020-12 tuple validation)contains,minContains,maxContainsunevaluatedItems
Primitive constraints
enumconstminimum,maximumexclusiveMinimum,exclusiveMaximum(numeric form per 2019-09/2020-12 + boolean legacy)multipleOfminLength,maxLengthpatternformatcontentEncoding,contentMediaType,contentSchema
Composition and conditional
allOfanyOfoneOfnotif,then,else
Fully Implemented Keywords
All keywords below are now fully enforced at runtime and verified by 373 unit tests across 23 validator classes.
Array Keywords
minItems— Minimum array lengthmaxItems— Maximum array lengthuniqueItems— Uniqueness constraintprefixItems— Tuple validation (2019-09+)items— Schema for array elementscontains/minContains/maxContains— Match-count constraintsunevaluatedItems— Post-evaluation array-item constraintsadditionalItems— Limited support (applies only whenprefixItemsis defined; standarditemskeyword behavior is fully supported)
Object Keywords
minProperties— Minimum property countmaxProperties— Maximum property countdependencies— Property and schema dependenciesdependentRequired— Required properties based on presence (2019-09+)dependentSchemas— Schema constraints based on presence (2019-09+)propertyNames— Property-name schema validationunevaluatedProperties— Post-evaluation object-property constraints
Reference Keywords
$ref— JSON Pointer reference resolution$dynamicRef/$dynamicAnchor— Dynamic reference and anchor support$defs/definitions— Schema definitions (definitionsas legacy alias;$defsis the Draft 2020-12+ preferred form)$id— Base URI for reference resolution$schema— Schema dialect identification
Metadata Keywords
title— Schema titledescription— Schema descriptiondefault— Default valueexamples— Example valuesreadOnly/writeOnly— Property constraintsdeprecated— Deprecation statuscontentEncoding/contentMediaType/contentSchema— Content vocabulary constraints$comment/comment— Annotations (commentas legacy alias)
Unsupported keyword handling
Unknown keywords are handled by FileSchemaLoader.detectUnsupportedKeywords():
strict-mode: false-> warning log, schema still loadsstrict-mode: true-> throws exception and aborts loading
Reference behavior ($ref)
- Full JSON Pointer resolution with navigation by:
- Keywords (
properties,items,additionalProperties) - Object keys (
properties/name) - Array indices (
prefixItems/0,allOf/1)
- Keywords (
- Support for
definitionsand$defssections - Escaping support for
~0(represents~) and~1(represents/) $id-based indexing for external reference resolution
Keyword Examples
Type and structure
type
{
"type": "string"
}
Validates that the value is a string.
properties
{
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"}
}
}
Defines schemas for specific object properties.
patternProperties
{
"type": "object",
"patternProperties": {
"^S_": {"type": "string"},
"^I_": {"type": "integer"}
}
}
Defines schemas for properties matching regex patterns.
required
{
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string"}
},
"required": ["name", "email"]
}
Specifies which properties must be present.
additionalProperties
{
"type": "object",
"properties": {
"name": {"type": "string"}
},
"additionalProperties": false
}
Controls whether additional properties are allowed.
propertyNames
{
"type": "object",
"propertyNames": {
"pattern": "^[A-Z][a-z]+$"
}
}
Validates property names against a schema.
items
{
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
}
Defines schema for all array elements.
prefixItems
{
"type": "array",
"prefixItems": [
{"type": "string"},
{"type": "integer"}
],
"items": false
}
Defines schemas for specific array positions (tuple validation).
contains / minContains / maxContains
{
"type": "array",
"contains": {"type": "integer"},
"minContains": 1,
"maxContains": 3
}
Requires at least one element to match the contains schema.
Primitive constraints
enum
{
"type": "string",
"enum": ["active", "inactive", "pending"]
}
Restricts value to a specific set.
const
{
"type": "string",
"const": "fixed-value"
}
Requires exact value match.
minimum / maximum
{
"type": "number",
"minimum": 0,
"maximum": 100
}
Sets inclusive numeric bounds.
exclusiveMinimum / exclusiveMaximum
{
"type": "number",
"exclusiveMinimum": 0,
"exclusiveMaximum": 100
}
Sets exclusive numeric bounds (value must be greater than 0 and less than 100).
multipleOf
{
"type": "number",
"multipleOf": 0.5
}
Requires value to be a multiple of specified number.
minLength / maxLength
{
"type": "string",
"minLength": 3,
"maxLength": 50
}
Constrains string length.
pattern
{
"type": "string",
"pattern": "^[A-Z][a-z]+$"
}
Validates string against regex pattern.
format
{
"type": "string",
"format": "email"
}
Validates string format (email, date, uri, etc.).
Composition and conditional
allOf
{
"allOf": [
{"type": "object"},
{"properties": {"name": {"type": "string"}}}
]
}
Value must validate against ALL schemas.
anyOf
{
"anyOf": [
{"type": "string"},
{"type": "integer"}
]
}
Value must validate against AT LEAST ONE schema.
oneOf
{
"oneOf": [
{"type": "string"},
{"type": "integer"}
]
}
Value must validate against EXACTLY ONE schema.
not
{
"not": {"type": "string"}
}
Value must NOT validate against the schema.
if / then / else
{
"type": "object",
"properties": {
"type": {"enum": ["user", "admin"]}
},
"if": {"properties": {"type": {"const": "admin"}}},
"then": {"properties": {"permissions": {"type": "array"}}},
"else": {"properties": {"permissions": {"type": "null"}}}
}
Applies conditional validation based on if/then/else logic.
Object Keywords
minProperties / maxProperties
{
"type": "object",
"minProperties": 1,
"maxProperties": 10
}
Constrains number of object properties.
dependencies
{
"type": "object",
"properties": {
"name": {"type": "string"},
"credit_card": {"type": "string"}
},
"dependencies": {
"credit_card": ["billing_address"]
}
}
Makes properties required based on presence of other properties.
dependentRequired
{
"type": "object",
"properties": {
"name": {"type": "string"},
"credit_card": {"type": "string"}
},
"dependentRequired": {
"credit_card": ["billing_address"]
}
}
Modern replacement for dependencies (2019-09+).
dependentSchemas
{
"type": "object",
"properties": {
"name": {"type": "string"}
},
"dependentSchemas": {
"name": {
"properties": {
"first": {"type": "string"},
"last": {"type": "string"}
},
"required": ["first", "last"]
}
}
}
Applies schema constraints based on property presence (2019-09+).
Reference Keywords
$ref
{
"$defs": {
"address": {
"type": "object",
"properties": {
"street": {"type": "string"}
}
}
},
"type": "object",
"properties": {
"billing": {"$ref": "#/$defs/address"}
}
}
References another schema definition.
$defs / definitions
{
"$defs": {
"person": {
"type": "object",
"properties": {
"name": {"type": "string"}
}
}
}
}
Defines reusable schema components.
Metadata Keywords
title / description
{
"title": "User Profile",
"description": "Schema for user profile validation",
"type": "object"
}
Provides human-readable documentation.
default
{
"type": "object",
"properties": {
"status": {
"type": "string",
"default": "active"
}
}
}
Specifies default value if property is missing.
examples
{
"type": "object",
"properties": {
"name": {
"type": "string",
"examples": ["John", "Jane"]
}
}
}
Provides example values for documentation.
readOnly / writeOnly
{
"type": "object",
"properties": {
"id": {
"type": "string",
"readOnly": true
},
"password": {
"type": "string",
"writeOnly": true
}
}
}
Marks properties as read-only or write-only.
deprecated
{
"type": "object",
"properties": {
"oldField": {
"type": "string",
"deprecated": true
}
}
}
Marks property as deprecated.
Source mapping
- Parse and unsupported detection:
FileSchemaLoader.java - Supported keyword registry:
SupportedKeywordsRegistry.java - Runtime enforcement:
ObjectValidator.java,ArrayValidator.java,PrimitiveValidator.java,FormatValidator.java
Related pages
- Runtime execution order: Validation behavior
- Skript-facing constraints: Skript API
- Supported format catalog: Format reference