Function: toStandardValidator()
ts
function toStandardValidator<T>(schema): FusionValidator<T>;Defined in: packages/core/src/core/StandardSchema.ts:125
Create a FusionValidator from a Standard Schema v1 compatible schema.
This is the primary entry point for non-Zod validators. Any schema library implementing the Standard Schema spec can be used directly.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | StandardSchemaV1<unknown, T> | A Standard Schema v1 compatible schema |
Returns
A FusionValidator wrapping the schema
Example
typescript
import * as v from 'valibot'; // ~1kb tree-shaken
const schema = v.object({ name: v.string() });
const validator = toStandardValidator(schema);
const ok = validator.validate({ name: 'Alice' });
// { success: true, data: { name: 'Alice' } }
const err = validator.validate({ name: 42 });
// { success: false, issues: [{ message: 'Expected string', path: ['name'] }] }