Skip to content

Commit

Permalink
Add reset feature. Readme update.
Browse files Browse the repository at this point in the history
  • Loading branch information
NewOldMax committed Dec 26, 2017
1 parent 8a2e522 commit 2ac7f96
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,24 @@ ValidatorForm.addValidationRule('isPasswordMatch', (value) => {

#### ValidatorForm

+ Props

| Prop | Required | Type | Default value | Description |
|-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------|
| onSubmit | true | function | | Callback for form that fires when all validations are passed |
| instantValidate | false | bool | true | If true, form will be validated after each field change. If false, form will be validated only after clicking submit button. |
| onError | false | function | | Callback for form that fires when some of validations are not passed. It will return array of elements which not valid. |

+ Methods

| Name | Params | Return | Descriptipon |
|------------------|--------|--------|----------------------------------------------------|
| resetValidations | | | Reset validation messages for all validated inputs |

#### All validated fields (ValidatorComponent)

+ Props

| Prop | Required | Type | Default value | Description |
|-----------------|----------|----------|---------------|----------------------------------------------------------------------------------------|
| validators | false | array | | Array of validators. See list of default validators above. |
Expand All @@ -123,6 +133,15 @@ ValidatorForm.addValidationRule('isPasswordMatch', (value) => {
| validatorListener | false | function | | It triggers after each validation. It will return `true` or `false` |
| withRequiredValidator | false | bool | | Allow to use `required` validator in any validation trigger, not only form submit |

+ Methods

| Name | Params | Return | Descriptipon |
|------------------|--------|--------|----------------------------------------------------|
| getErrorMessage | | | Get error validation message |
| validate | value: any, includeRequired: bool | | Run validation for current component |
| isValid | | bool | Return current validation state |
| makeInvalid | | | Set invalid validation state |

### Implemetations

+ [material-ui](https://www.npmjs.com/package/react-material-ui-form-validator)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-form-validator-core",
"version": "0.2.0",
"version": "0.3.0",
"description": "Core validator component for react forms.",
"main": "./lib/index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/ValidatorForm.jsx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class ValidatorForm extends React.Component {
return null;
}

resetValidations() {
this.childs.map(child => child.setState({ isValid: true }));
}

render() {
// eslint-disable-next-line
const { onSubmit, instantValidate, onError, ...rest } = this.props;
Expand Down

0 comments on commit 2ac7f96

Please sign in to comment.