It should be easy to integrate with SvelteKit Form Actions so a single set of validation errors can be used for both client-side and server-side validation.
It should just be a case of setting the initial validation state from the ActionData returned from the server, probably a case of "use the standard ValidityState flags when returning the state on the server")
Then the hints setup for client-side validation could be re-used:
{#if $email.valueMissing}Email address is required{/if}
{#if $email.typeMismatch}Not a valid email address{/if}
{#if $email.customError}Invalid credentials{/if}
Obviously, the form couldn't be submitted if it fails to verify with the standard inbuilt browser validations, but it's useful to be able to re-used state and it's possible that one POST happened to not load the JS and another one does, so this should work with either.
It should be easy to integrate with SvelteKit Form Actions so a single set of validation errors can be used for both client-side and server-side validation.
It should just be a case of setting the initial validation state from the
ActionData
returned from the server, probably a case of "use the standardValidityState
flags when returning the state on the server")So instead of the example in the SK docs:
It should return the validation errors for each field using the standard validation flags:
And on the client we'd probably do something like:
Then the hints setup for client-side validation could be re-used:
Obviously, the form couldn't be submitted if it fails to verify with the standard inbuilt browser validations, but it's useful to be able to re-used state and it's possible that one POST happened to not load the JS and another one does, so this should work with either.