Skip to content

Commit

Permalink
Add ability to allow required validation in any validation case.
Browse files Browse the repository at this point in the history
  • Loading branch information
NewOldMax committed Dec 5, 2017
1 parent 7b2dea3 commit 8a2e522
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Readme.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ ValidatorForm.addValidationRule('isPasswordMatch', (value) => {
| errorMessages | false | array | | Array of error messages. Order of messages should be the same as `validators` prop. |
| name | true | string | | Name of input |
| 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 |

### Implemetations

+ [material-ui](https://www.npmjs.com/package/react-material-ui-form-validator)

### Contributing

This component covers all my needs, but feel free to contribute.
This component covers all my needs, but feel free to contribute.
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.1.3",
"version": "0.2.0",
"description": "Core validator component for react forms.",
"main": "./lib/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/ValidatorComponent.jsx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ValidatorComponent extends React.Component {

componentWillReceiveProps(nextProps) {
if (this.instantValidate && nextProps.value !== this.props.value) {
this.validate(nextProps.value);
this.validate(nextProps.value, nextProps.withRequiredValidator);
}
if (nextProps.validators && nextProps.errorMessages &&
(this.props.validators !== nextProps.validators || this.props.errorMessages !== nextProps.errorMessages)) {
Expand Down Expand Up @@ -95,7 +95,6 @@ class ValidatorComponent extends React.Component {
});
}


isValid() {
return this.state.isValid;
}
Expand All @@ -118,6 +117,7 @@ ValidatorComponent.propTypes = {
name: PropTypes.string,
value: PropTypes.any,
validatorListener: PropTypes.func,
withRequiredValidator: PropTypes.bool,
};

ValidatorComponent.defaultProps = {
Expand Down

0 comments on commit 8a2e522

Please sign in to comment.