Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.04 KB

File metadata and controls

26 lines (20 loc) · 1.04 KB

Zod Utilities

⚠️ Deprecated: These utilities are deprecated and will be removed in the next major release.

The Zod Utilities are provided under the conformal/zod subpath. Zod is an optional peer dependency, so you can freely choose another Standard Schema library if you prefer without depending on Zod.

Field Schemas

Conformal's field schemas are preprocessing wrappers that handle common form input patterns automatically. They convert empty strings to undefined, coerce string inputs to appropriate types (numbers, dates, booleans), and handle File objects. They're fully compatible with Zod and can be mixed with regular Zod schemas.

import * as zf from "conformal/zod";

const formSchema = zf.object({
  name: zf.string().optional(),
  email: zf.email(),
  age: zf.number(),
  hobbies: zf.array(zf.string()),
  birthDate: zf.date(),
  acceptTerms: zf.boolean(),
  profilePicture: zf.file(),
  accountType: zf.enum(["personal", "business"]),
  website: zf.url().optional(),
  transactionAmount: zf.bigint(),
});