Skip to content

Yup

Yup is a JavaScript schema builder for value parsing and validation. It is a library that allows you to define a schema for your data and validate it.

Installation

pnpm add @faivform/yup yup

Usage

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

<script>
import { faivform, Field } from "@tuentyfaiv/svelte-form";
import { adapter } from "@faivform/yup";
import * as yup from "yup";
const schema = yup.object().shape({
name: yup.string().required(),
age: yup.number().required(),
email: yup.string().email(),
});
type Schema = typeof schema;
type Fields = yup.InferType<Schema>;
const form = faivform<Schema, Fields>({ fields: adapter(schema) });
// ... rest of the code
</script>

Example