Skip to content

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:

  1. Accepts schema definitions in the library’s native format
  2. Infers TJobTypeDefinitions from the schemas (providing the same compile-time safety as defineJobTypes)
  3. Calls createJobTypes with validation functions that delegate to the schema library

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.

The JobTypes object validates at each boundary:

Job Type DefinitionMethodPurpose
(all)getTypeNamesReturns known type names (for merge/routing)
entry?: booleanvalidateEntryValidates job type can start a chain
input: unknownparseInputParses and validates job input
output?: unknownparseOutputParses and validates job output
continueWith?: ReferencevalidateContinueWithValidates continuation target
blockers?: Reference[]validateBlockersValidates blocker references

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 validation
  • message: Human-readable error message
  • details: Additional context (original error, input value, etc.)

Complete adapter implementations for each library:

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.