Skip to content

Runtime Validation

Queuert’s runtime validation follows an adapter pattern. The core provides createJobTypeRegistry, which accepts raw validation functions. Schema-specific adapters (Zod, Valibot, TypeBox, ArkType) are implemented in user-land, wrapping their respective schema libraries into the registry 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 defineJobTypeRegistry)
  3. Calls createJobTypeRegistry with validation functions that delegate to the schema library

defineJobTypeRegistry vs createJobTypeRegistry

Section titled “defineJobTypeRegistry vs createJobTypeRegistry”

defineJobTypeRegistry 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.

createJobTypeRegistry 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 registry validates at each boundary:

Job Type DefinitionRegistry MethodPurpose
(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: