Validation Adapters
Queuert’s runtime validation follows an adapter pattern. The core provides createJobTypes, which accepts raw validation functions. Schema-specific adapters (Zod, Valibot, TypeBox, ArkType) are implemented in user-land, wrapping their respective schema libraries into the JobTypes interface.
Each adapter:
- Accepts schema definitions in the library’s native format
- Infers
TJobTypeDefinitionsfrom the schemas (providing the same compile-time safety asdefineJobTypes) - Calls
createJobTypeswith validation functions that delegate to the schema library
defineJobTypes vs createJobTypes
Section titled “defineJobTypes vs createJobTypes”defineJobTypes is a lightweight type-only helper. It provides compile-time type inference with zero runtime cost — no validation functions are executed. Use it when your inputs come from trusted internal code.
createJobTypes adds runtime validation on top of compile-time types. It accepts validation functions for entry checks, input/output parsing, continuation validation, and blocker validation. Use it when your job inputs originate from external sources (APIs, webhooks, user input) where compile-time guarantees alone are insufficient.
JobTypes Interface
Section titled “JobTypes Interface”The JobTypes object validates at each boundary:
| Job Type Definition | Method | Purpose |
|---|---|---|
| (all) | getTypeNames | Returns known type names (for merge/routing) |
entry?: boolean | validateEntry | Validates job type can start a chain |
input: unknown | parseInput | Parses and validates job input |
output?: unknown | parseOutput | Parses and validates job output |
continueWith?: Reference | validateContinueWith | Validates continuation target |
blockers?: Reference[] | validateBlockers | Validates blocker references |
Error Handling
Section titled “Error Handling”All validation errors throw JobTypeValidationError with:
code: Error type ('invalid_input','invalid_output','invalid_continuation','invalid_blockers','not_entry_point')typeName: The job type that failed validationmessage: Human-readable error messagedetails: Additional context (original error, input value, etc.)
Example Adapters
Section titled “Example Adapters”Complete adapter implementations for each library:
Conformance Testing
Section titled “Conformance Testing”Custom validation adapters can be validated against Queuert’s conformance suite via runValidationAdapterConformance from queuert/conformance. The suite combines runtime checks (six-method contract, error wrapping) with type-level checks (schema-to-shape inference) — the fixture’s builder return types enforce the type contract at the call site, so inference bugs surface as compile errors before the runtime suite runs. See Custom Adapters for the full pattern.
See Also
Section titled “See Also”- Runtime Validation Guide — When to use runtime validation
- Chain Patterns — Continuation references and patterns
- Custom Adapters — Building and validating a custom validation adapter
- Conformance Reference — Runner API and fixture types