Validation API Reference¶
Schema validation and type coercion utilities used at the network boundary.
SchemaValidationError
¶
Bases: Exception
Raised when incoming parameters fail schema validation.
Source code in src/istos/validation.py
build_payload_validator(func, param_name)
¶
Precompile a validator for a single-value payload (@subscribe).
The network payload fills one positional slot (param_name) rather than a dict
of named params, so — unlike validate_params — this validates/coerces that one
value against its type hint via a TypeAdapter (handling both BaseModel and
scalar/generic hints uniformly).
Returns a callable value -> coerced_value, or None when there is nothing to
validate (no pydantic, no target param, or an untyped / Any hint) — in which
case callers should pass the payload through unchanged.
Source code in src/istos/validation.py
validate_params(func, params, skip_params=None)
¶
Validates and coerces incoming parameters against a function's type hints.
Supports three modes
- Function accepts a single Pydantic BaseModel → full model validation
- Function has typed parameters (int, str, float, etc.) → auto-coercion via dynamic model
- Function has no type hints → passthrough (no validation)
skip_params names parameters that are framework-injected (e.g. db or
Depends(...) dependencies) and must be excluded from network validation.
Returns the validated and type-coerced parameters as a dict. Raises SchemaValidationError if validation fails.