sveltekit-superforms
sveltekit-superforms copied to clipboard
$constraints empty in Client-Side-Mode
Description
I'm using Superforms with Valibot in SPA Mode but $constraints are empty ({}).
The form validation seems to be working and displays all errors correctly but when I want to use $constraints of a field it is empty.
const _userSchema = v.object({
text: v.pipe(v.string(), v.minLength(2), v.maxLength(10))
})
const formData = {
text: 'hallo'
}
const { form, errors, message, constraints, enhance } = superForm(
formData,
{
SPA: true,
validators: valibot(_userSchema),
validationMethod: 'oninput'
}
);
$: console.log({$constraints}); // empty {}
I tried it with a Zod Schema but it's also empty.
When using the official tutorial (from docs) that is creating the form on the server then$constraints its populated correctly.
MRE
Valibot:
https://www.sveltelab.dev/9mybppcxpyhugni?files=.%2Fsrc%2Froutes%2F%2Bpage.svelte
Zod: https://www.sveltelab.dev/9mybppcxpyhugni?files=.%2Fsrc%2Froutes%2Fzod%2F%2Bpage.svelte