Yup validator for Svelte
Elegant
Using Svelte actions
Full yup support
Usage
<script lang="ts">
import validator from "svup";
import { string } from "yup";
const { register, isValid, onSubmit, errors } = validator({
validateOnInput: true,
schema: {
email: string().required().email(),
password: string().required().min(8),
},
});
</script>
<form on:submit(onSubmit(console.log))>
<input type="email" name="email" use:register />
<input type="password" name="password" use:register />
<button disabled={!$isValid}>Submit</button>
</form>
Options
schema
(required): The validation schema to test against.
-
Returns
-
-
errors
is a Readable<boolean>
store what contains the error messages from yup schema.
-
NOTE