Open
Description
After examining the available form validation libraries, I come to the conclusion that a custom Form
component would be the cleanest way of form validation with SvelteUI.
The TextInput
field could integrate the on:blur
, on:change
, on:input
event handlers, the bind:value
, and the error
message using the context API.
I would recommend schema based validation with Zod. For more advanced use cases, a custom validation function could be specified.
<script>
import { Form, TextInput } from '@svelteuidev/core';
import * as zod from 'zod';
const mySchema = z.object({
username: z.string(),
password: z.string(),
};
</script>
<Form schema={mySchema}>
<TextInput name="username"/>
<TextInput name="password" type="password"/>
</Form>
Do you want to contribute this feature and create a pull request
Yes
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status