Saltearse al contenido

Zod

Esta página aún no está disponible en tu idioma.

Zod is a TypeScript-first schema declaration and validation library. It is a library that allows you to define a schema for your data and validate it.

Installation

pnpm add @faivform/zod zod

Usage

You need to create a schema using Zod and then pass it through the adapter to the faivform function.

<script lang="ts">
import { faivform, Field } from "@tuentyfaiv/svelte-form";
import { adapter } from "@faivform/zod";
import { z } from "zod";
const schema = z.object({
name: z.string(),
age: z.number(),
email: z.string().email(),
});
type Schema = typeof schema;
type Fields = z.infer<Schema>;
const form = faivform<Schema, Fields>({ fields: adapter(schema) });
// ... rest of the code
</script>

Example