Skip to content

Commit

Permalink
Fix file validators, add new rules functions, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NewOldMax committed Jun 16, 2020
1 parent 4b86d9c commit db2266d
Show file tree
Hide file tree
Showing 6 changed files with 798 additions and 696 deletions.
25 changes: 20 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,17 @@ ValidatorForm.addValidationRule('isPasswordMatch', (value) => {
return true;
});
````
And remove them
Get them
````javascript
componentWillUnmount() {
ValidatorForm.removeValidationRule('isPasswordMatch');
}
ValidatorForm.getValidationRule('isPasswordMatch');
````
Remove them
````javascript
ValidatorForm.removeValidationRule('isPasswordMatch');
````
And check is validation rule already in list
````javascript
ValidatorForm.hasValidationRule('isPasswordMatch');
````

### API
Expand All @@ -175,13 +181,22 @@ componentWillUnmount() {
| onError | false | function | | Callback for form that fires when some of validations are not passed. It will return array of elements which not valid. |
| debounceTime | false | number | 0 | Debounce time for validation i.e. your validation will run after `debounceTime` ms when you stop changing your input |

+ Methods
+ Instance methods (via ref)

| Name | Params | Return | Description |
|------------------|--------|--------|----------------------------------------------------|
| resetValidations | | | Reset validation messages for all validated inputs |
| isFormValid | dryRun: bool (default true) | Promise | Get form validation state in a Promise (`true` if whole form is valid). Run with `dryRun = false` to show validation errors on form |

+ Static methods (via class)

| Name | Params | Return | Description |
|------------------|--------|--------|----------------------------------------------------|
| addValidationRule | name: string, callback: function | | Add new validation rule |
| getValidationRule | name: string | function | Get validation rule by name |
| hasValidationRule | name: string | bool | Check if rule exsits |
| removeValidationRule | name: string | | Remove validation rule |

#### All validated fields (ValidatorComponent)

+ Props
Expand Down
Loading

0 comments on commit db2266d

Please sign in to comment.