1.2.10 • Published 3 months ago

@felte/reporter-solid v1.2.10

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

@felte/reporter-solid

Tests Bundle size NPM Version codecov

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

Installation

# npm
npm i -S @felte/reporter-solid

# yarn
yarn add @felte/reporter-solid

Usage

The package exports a reporter function and a ValidationMessage component. Pass the reporter function to the extend option of createForm and add the ValidationMessage component wherever you want your validation messages to be displayed.

The ValidationMessage component needs a for prop set with the name of the input it corresponds to, the child of ValidationMessage is a function that takes the error messages as an argument. This can be either a string, an array of strings, or undefined.

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

export function Form() {
  const { form } = createForm({
      // ...
      extend: reporter,
      // ...
    },
  })

  return (
    <form use:form>
      <input id="email" type="text" name="email" />
      <ValidationMessage for="email">
        <!-- We assume a there's only going to be one message -->
        {(message) => <span>{message?.[0]}</span>}
      </ValidationMessage>
      <input type="password" name="password" />
      <ValidationMessage for="password">
        {(message) => <span>{message?.[0]}</span>}
      </ValidationMessage>
      <input type="submit" value="Sign in" />
    </form>
  );
}

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">
  {(message) => <span>{message?.[0]}</span>}
</ValidationMessage>
1.2.10

3 months ago

1.2.9

8 months ago

1.2.8

11 months ago

1.2.7

11 months ago

1.2.5

1 year ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.1

2 years ago

1.0.0-next.19

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0-next.18

2 years ago

1.0.0

2 years ago

1.0.0-next.17

2 years ago

1.0.0-next.16

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

1.0.0-next.11

2 years ago

1.0.0-next.10

2 years ago

1.0.0-next.15

2 years ago

1.0.0-next.14

2 years ago

1.0.0-next.13

2 years ago

1.1.2

2 years ago

1.0.0-next.12

2 years ago

1.0.0-next.0

2 years ago

1.0.0-next.1

2 years ago

1.0.0-next.2

2 years ago

1.0.0-next.22

2 years ago

1.0.0-next.21

2 years ago

1.0.0-next.20

2 years ago

1.0.0-next.24

2 years ago

1.0.0-next.23

2 years ago

1.0.0-next.3

2 years ago

1.0.0-next.4

2 years ago

1.0.0-next.5

2 years ago

1.0.0-next.6

2 years ago

1.0.0-next.7

2 years ago

1.0.0-next.8

2 years ago

1.0.0-next.9

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago