Skip to content

[Feature Request] Form component #369

Open
@notramo

Description

@notramo

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

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions