Skip to content

Commit

Permalink
Update README docs
Browse files Browse the repository at this point in the history
  • Loading branch information
audiolion committed Aug 10, 2017
1 parent fb3d37e commit 26bc402
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,7 @@ import Form from 'react-validify'
<Form
initialValues={{email: 'test'}} //optional
rules={{ email: 'email|required', password: 'required|min:8' }}
errorMessages={{'required.email': 'Custom error message', 'min.password': 'Custom min password required error message.'}} //optional
>
<Input name="email" />
<Input name="password" type="password" />
Expand All @@ -32,6 +33,7 @@ import Form from 'react-validify'

This component is the simplest way to validate form inputs in React. There's two things to learn. The Form accepts a prop called `rules`. This is an object with the names of all yours inputs and the rules for them. Rules can be found [here](https://github.com/skaterdav85/validatorjs#available-rules). Place the `submit` prop on any element that you want to trigger the validation. The onClick will not be triggered until the rules pass. If validation fails, error messages will be passed to the inputs as an error prop.

The `errorMessages` prop on `Form` is optional and allows you provide custom error messages as specified by [validatorjs's docs](https://github.com/skaterdav85/validatorjs#custom-error-messages).

Workflow:

Expand Down

0 comments on commit 26bc402

Please sign in to comment.