Skip to content

Commit

Permalink
Add removeValidationRule
Browse files Browse the repository at this point in the history
  • Loading branch information
NewOldMax committed Jun 10, 2019
1 parent ebe3a3b commit 462d3b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ ValidatorForm.addValidationRule('isPasswordMatch', (value) => {
return true;
});
````
And remove them
````javascript
componentWillUnmount() {
ValidatorForm.removeValidationRule('isPasswordMatch');
}
````

### API

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.6.3",
"version": "0.6.4",
"description": "Core validator component for react forms.",
"main": "./lib/index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/ValidatorForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ ValidatorForm.addValidationRule = (name, callback) => {
Rules[name] = callback;
};

ValidatorForm.removeValidationRule = (name) => {
delete Rules[name];
};

ValidatorForm.childContextTypes = {
form: PropTypes.object,
};
Expand Down

0 comments on commit 462d3b2

Please sign in to comment.