Regle Schemas
Regle can drive validation from a schema library instead of @regle/rules. Install @regle/schemas and use useRegleSchema with a Zod, Valibot, or ArkType schema (or any Standard Schema compliant validator).
import { useRegleSchema } from '@regle/schemas';
import { z } from 'zod';
const { r$ } = useRegleSchema(
{ email: '' },
z.object({ email: z.string().email() })
);
Key Concepts
useRegleSchema(state, schema)replacesuseRegle; ther$object behaves the same.- Works with any Standard Schema library; Zod, Valibot, and ArkType are first-class.
useRules/refineRuleslet you mix schema validation with native Regle rules.InferInputinfers the state type from the schema.
References
| Topic | Description | Reference |
|---|---|---|
| Schema Libraries | useRegleSchema with Zod, Valibot, ArkType |
schemas-libraries |
| Standard Schema | Standard Schema spec, useRules, refineRules, InferInput |
schemas-standard-schema |
Related skills
- regle — form setup with
useRegle, validation properties, displaying errors. - regle-rules — native rules when not using a schema library.
- regle-typescript — type-safe output and typing props.