Skip to main content

What is Standard Schema?

Standard Schema v1 is a shared protocol that validation libraries implement so that frameworks can accept any compliant schema without coupling to a specific library. When a framework supports Standard Schema, it reads a ~standard property on your schema object to validate inputs in a uniform way. ts-chas implements this protocol automatically. Every guard chain you build with is.* and every schema you define with defineSchemas exposes the ~standard property — you don’t need to adapt or wrap anything.
The ~standard property is attached automatically to every guard chain produced by is.* and to every schema returned by defineSchemas. You never need to configure it manually.

Integration with tRPC

tRPC accepts any Standard Schema-compliant object as an input validator. You can use a raw is.* guard chain or a defineSchemas schema directly in your procedure definition.

Integration with react-hook-form

react-hook-form’s useForm accepts a resolver option. Libraries like @hookform/resolvers provide Standard Schema support, meaning you pass your guard or schema directly as the resolver value.
The resolver validates the form values against your schema on every submit, and maps GuardErr messages directly to react-hook-form’s errors object.

Integration with Drizzle

Drizzle’s queryClient and insert helpers accept Standard Schema validators for runtime validation of query inputs and results. Pass a guard or schema to Drizzle’s validation slot to enforce your types at the boundary between the database and your application code.
Even if a row from the database contains unexpected shapes — for example, after a migration that isn’t yet reflected in your types — the schema catches the mismatch before it silently propagates through your application.

Any Standard Schema-compatible library

Because ts-chas implements the Standard Schema v1 protocol, any library that supports it works with ts-chas guards out of the box. The pattern is always the same: find the library’s validation slot and pass a guard chain or a defineSchemas schema directly.
Check the documentation for the library you’re integrating with to find its Standard Schema resolver or validator option.