Constraints

Constraints restrict which values a field can hold. They are validated against the payload at runtime.

enum

enum

The enum keyword restricts a field to a fixed set of allowed values. Any payload value not in the list fails validation. Values can be strings, numbers, booleans, or null.

ValueStatusNote
"active"
valid
"inactive"
valid
"pending"
valid
"deleted"
invalid
not in the enum list
null
invalid
null is not listed

Mixed types

An enum array can hold values of different types.

ValueStatusNote
"active"
valid
"inactive"
valid
null
valid
42
invalid
not in the list
"pending"
invalid
not in the list