mantine-class-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

maintine-class-validator

Use class-validator with Mantine forms

Example

const form = useForm<CreateReviewDTO>({
    dto: new CreateReviewDTO(),
    initialValues: {
        title: props.myReview?.title || '',
        rating: props.myReview?.rating || 0,
        review: props.myReview?.review || '',
        reviewNameType: ReviewNameType.Anonymous
      },
    transform: (dto: CreateReviewDTO) => {
        dto.rating = parseInt(dto.rating as unknown as string) || 0;
        dto.reviewNameType = parseInt(dto.reviewNameType as unknown as string) || 0;
        return dto;
      }
});

Extra

There is type safety with form fields, by accessing form.fields:

<TextInput label="Title" {...form.getInputProps(form.fields.title)}/>

Readme

Keywords

none

Package Sidebar

Install

npm i mantine-class-validator

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

3.6 kB

Total Files

6

Last publish

Collaborators

  • doelfke