@faivform/zod
v1.0.1
Published
Adapter to use Zod with @tuentyfaiv/svelte-form
Downloads
38
Maintainers
Readme
Faivform zod adapter
This package provides a zod adapter for faivform
You can check the documentation for more information.
Installation
npm install @faivform/zod
Basic example
<script lang="ts">
import { Field } from "@tuentyfaiv/svelte-form";
import { adapter } from "@faivform/zod";
import { signinSchema } from "./your-schema/path";
const form = faivform({ fields: adapter(signinSchema) });
const { submit } = $form;
// or
$: form = faivform({ fields: adapter(signinSchema) });
$: ({ submit } = $form);
const onSubmit = submit(async (values) => {
// your logic
});
</script>
<form on:submit|preventDefault={onSubmit}>
<Field name="email" type="email" label="Email" />
<Field name="password" type="password" label="Password" />
// ... other inputs
<button type="submit">Submit</button>
</form>