Function: fromZodSchema()
ts
function fromZodSchema<T>(schema): FusionValidator<T>;Defined in: packages/core/src/core/StandardSchema.ts:176
Create a FusionValidator from a raw Zod schema.
This adapter uses Zod's .safeParse() method and maps the result to the standard FusionValidator interface.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | ZodSchemaLike<T> | A Zod schema (z.object, z.string, etc.) |
Returns
A FusionValidator wrapping the Zod schema
Example
typescript
import { z } from 'zod';
const schema = z.object({ name: z.string() });
const validator = fromZodSchema(schema);
const ok = validator.validate({ name: 'Alice' });
// { success: true, data: { name: 'Alice' } }