Schemas and validation
Overview
Section titled “Overview”Use a Schema to describe and validate data arriving at an HTTP route, a Realtime method or an MCP tool. Declare Python field types, attach structural bounds such as minimum length and add application rules such as email or password confirmation. A successful validation returns an instance whose fields you can use; invalid input produces errors keyed by field.
Schemas use msgspec.Struct internally. Field aliases typing.Annotated; Orionis compiles its constraints and rule plans when the class is declared.
The package separates declaration from validation. Direct construction trusts already typed Python values under msgspec constructor semantics. orionis.schemas.validator.Schema.validate() and validateAsync() convert untrusted payloads and raise an Orionis ValidationException containing field-indexed failures.
Requirements
Section titled “Requirements”- Python 3.14 or newer; schema compilation relies on deferred annotation evaluation.
- Explicit imports from
fields,constraints,metadata,rules,validator, andexceptionsfor advanced features; the package root deliberately exports onlySchema. - A booted database connection for
Unique, and network/file context for rules that perform those checks.