<script>
import { useForm, validators, Hint, minLength } from "svelte-use-form@2.0.0";
const form = useForm();
// We could also define the valdidator here
// const form = useForm({
// minimalExample: { validators: [minLength(5)] }
// })
</script>
<form use:form>
<input name="minimalExample" use:validators={[minLength(5)]} />
<Hint for="minimalExample" on="minLength" let:value>
The title requires at least {value} characters.
</Hint>
<button disabled={!$form.valid}>Submit</button> <br />
</form>
<pre>
{JSON.stringify($form, null, " ")}
</pre>
<style>
:global(.touched:invalid) {
border-color: red;
outline-color: red;
}
</style>