Schemas
Scalar Declarations
scalar HANDLE = string & len(3..24) & pattern(/^[a-z][a-z0-9_]*$/)
Scalar declarations can refine:
- primitive types
- built-in scalar targets
- named scalar declarations
Predicate forms are:
enum(value1, value2, ...)where each value is a quoted string, integer, decimal number,true,false, ornullformat(NAME)whereNAMEis one ofUUID,EMAIL,NUMBER,DATE,DATE_TIME,TIME, orURIlen(min..max)for string length checks with inclusive integer bounds; either bound may be omitted as inlen(3..)orlen(..24), but not bothpattern(/regex/)for string checks against a slash-delimited regular expressionrange(min..max)for numeric checks with inclusive integer or decimal bounds; either bound may be omitted as inrange(0..)orrange(..10.5), but not both
Scalar and schema references are resolved after the full preprocessed collection is loaded, so forward references are allowed across the collection preamble and imported fragments.
Schema Declarations
scalar Food = enum("pizza", "taco", "salad")
schema Address {
city: string
postalCode: string
}
schema User {
id: UUID
email: EMAIL
birthday?: DATE?
favoriteFood?: Food
address: Address
}
schema Users = User[]
- object fields are open by default in v1
- schema fields can reference named scalar declarations alongside built-in scalar targets and other schemas
field?: Typemarks an optional fieldType?marks a nullable valueschema Name = Type[]defines a root-array schema
Imported fragments can contribute reusable scalar and schema declarations before request parsing.
Built-In Targets
Built-in scalar targets include:
UUIDEMAILNUMBERDATEDATE_TIMETIMEURI
Those names are reserved and cannot be redefined.
Built-in scalar targets are always available; you do not need to declare them locally.
Assertion Use
^ & body.id === UUID
^ & body.total === NUMBER
^ & body === User
Use schema targets when you want typed validation instead of plain string comparison.