1.2.0 • Published 8 months ago

@felte/reporter-svelte v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@felte/reporter-svelte

Tests Bundle size NPM Version codecov

A Felte reporter that uses a custom Svelte component to report errors.

Installation

npm install --save @felte/reporter-svelte

# Or, if you use yarn

yarn add @felte/reporter-svelte

If you're using sapper, you might want to add this reporter as a dev dependency. You can do this by adding the -D flag to any of the commands above.

Usage

The package exports a reporter function reporter and a Svelte component ValidationMessage. These can be used in conjunction to report errors.

Add the reporter to the extend property of createForm configuration.

import { reporter, ValidationMessage } from '@felte/reporter-svelte';

const { form } = createForm({
  // ...
  extend: reporter,
  // ...
});

In order to show the errors for a field, you'll need to use the reporter's component. For example

<label for="email">Email:</label>
<input id="email" name="email" aria-describedby="email-validation">
<ValidationMessage for="email" let:messages={messages}>
  {messages?.[0] || ''}
</ValidationMessage>

The for property refers to the ID of the input. The messages prop will have whatever the current value of that field's error is. If you want to have a placeholder element be shown instead of handling falsy error values yourself, you can use the placeholder slot.

<ValidationMessage for="email" let:messages={message}>
  <span>{message?.[0]}</span>
  <span slot="placeholder">Some placeholder text</span>
</ValidationMessage>

Warnings

This reporter can help you display your warning messages as well. If you want your ValidationMessage component to display the warnings for a field you'll need to set the level prop to the value warning. By default this prop has a value of error.

<ValidationMessage level="warning" for="email" let:messages={messages}>
  {messages?.[0] || ''}
</ValidationMessage>
1.2.0

8 months ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.0-next.19

3 years ago

1.0.1

3 years ago

1.0.0-next.18

3 years ago

1.0.0

3 years ago

1.0.0-next.17

3 years ago

1.0.0-next.16

3 years ago

1.0.0-next.11

3 years ago

1.0.0-next.10

3 years ago

1.0.0-next.15

3 years ago

1.0.0-next.14

3 years ago

1.0.0-next.13

3 years ago

1.0.0-next.12

3 years ago

0.3.20

4 years ago

1.0.0-next.0

3 years ago

1.0.0-next.1

3 years ago

1.0.0-next.2

3 years ago

1.0.0-next.3

3 years ago

1.0.0-next.4

3 years ago

1.0.0-next.5

3 years ago

1.0.0-next.6

3 years ago

1.0.0-next.7

3 years ago

1.0.0-next.8

3 years ago

1.0.0-next.9

3 years ago

1.0.0-next.22

3 years ago

1.0.0-next.21

3 years ago

1.0.0-next.20

3 years ago

1.0.0-next.23

3 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.3.17

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.9

4 years ago

0.3.10

4 years ago

0.3.8

4 years ago

0.3.6

4 years ago

0.3.7

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.17

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.11

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.4

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago