0.0.7 • Published 3 years ago

@dmitry.olyenyov/effector-persist v0.0.7

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

final-form-validations

set of validators to use with final-form or redux-form

NPM JavaScript Style Guide

Install

yarn add final-form-validations

Usage

import React, { Component } from "react";
import { Form, Field } from "rect-final-form";

import {
  createValidator,
  composeFieldValidators,
  required,
  minLength,
  maxLength,
  lessOrEqual,
} from "@dmitry.olyenyov/final-form-validations";

const validators = createValidator({
  lastName: [
    requried("Required!"),
    minLength(2, "Please enter at least 2 chars"),
    maxLength(500, "Name is too long"),
  ],
  description: required("Required!"),
});

class Example extends Component {
  render() {
    return (
      <Form onSubmit={() => {}} validate={validators}>
        <Field name="lastName" component="input" />
        <Field name="description" component="input" />
        <Field
          name="someField"
          component="input"
          validate={composeFieldValidators(
            required("Required!"),
            lessOrEqual(1000, "Must be less than 1000")
          )}
        />
      </Form>
    );
  }
}

License

MIT © Dema

0.0.7

3 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago