react-redux-form-validation

1.1.0 • Public • Published

react-form-validation

A helper library to redux-form to implement better validation.

circleci.com codecov.io Dependency Status devDependency Status peerDependency Status

How to install

npm install react-redux-form-validation react react-dom react-redux redux redux-form redux-thunk --save

How to use

Import and use the react-form-validation components, in stead of the corresponding redux-form components.

import { LabelledField, validForm, rules } from 'react-redux-form-validation';

In your form use the react-form-validation components.

<LabelledField name="title" type="text">
    Title Label
</LabelledField>

When making your redux-form use react-form-validation's validForm method, and pass it a validate prop for the fields that you want to validate. react-form-validation also provides rules that you can use to simplify the declaration.

const myValidForm = validForm({
    form: 'my-form',
    onSubmit: onSubmit,
    validate: {
        title: [rules.required],
        field-two: [rules.required, rules.contains('content')]
    }
})(ValidFormComponent);

finaly, you have to use the react-form-validation reducer in stead of the redux-form reducer.

import { reducer as formReducer } from 'react-redux-form-validation';

export default combineReducers({
    form: formReducer
});

An example can be seen in the example

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.05latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.05
1.0.10
1.0.01
0.0.140
0.0.130
0.0.120
0.0.110
0.0.100
0.0.91
0.0.81
0.0.70
0.0.61
0.0.51
0.0.41
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i react-redux-form-validation

Weekly Downloads

11

Version

1.1.0

License

X11

Unpacked Size

507 kB

Total Files

39

Last publish

Collaborators

  • nutgaard