Basics
This page covers the fundamental concepts of YAML Schema, including empty schemas, boolean schemas, and basic type validation.
Empty Schema
An empty schema accepts any valid YAML value:
# Schema
Valid examples:
42
"I'm a string"
an:
- arbitrarily
- nested
data: structure
Boolean Schemas
true Schema
A schema with the value true accepts any value:
# Schema
true
Valid examples:
42
"I'm a string"
an:
- arbitrarily
- nested
data: structure
false Schema
A schema with the value false rejects all values:
# Schema
false
Invalid examples:
42
"I'm a string"
an:
- arbitrarily
- nested
data: structure
Type Validation
Supported Types
YAML Schema supports the following types:
stringnumberintegerbooleannullobjectarray
Invalid Type Error
If you specify an unsupported type, validation will fail:
# Schema
type: foo
Error: Unsupported type: Expected type: string, number, integer, boolean, null, object, or array, but got: foo
String Type
# Schema
type: string
Valid examples:
""
"I'm a string"
Invalid examples:
42
an:
- arbitrarily
- nested
data: structure
Number Type
# Schema
type: number
Valid examples:
42
3.14
Invalid examples:
"I'm a string"
an:
- arbitrarily
- nested
data: structure
Object Type with Properties
# Schema
type: object
properties:
foo:
type: string
bar:
type: number
Valid examples:
foo: "I'm a string"
bar: 42
foo: "I'm a string"
Invalid examples:
foo: 42
bar: "I'm a string"
Error: [1:6] .foo: Expected a string, but got: Value(Integer(42))
Note: Missing properties are allowed by default unless required properties are specified.