Last active
September 2, 2018 09:44
-
-
Save agoiabel/486cbe3c560a743b4fc9dc5733ebb2cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const validate = (value, rules) => { | |
| let isValid = true; | |
| for (let rule in rules) { | |
| switch (rule) { | |
| case 'minLength': isValid = isValid && minLengthValidator(value, rules[rule]); break; | |
| default: isValid = true; | |
| } | |
| } | |
| return isValid; | |
| } | |
| /** | |
| * minLength Val | |
| * @param value | |
| * @param minLength | |
| * @return | |
| */ | |
| const minLengthValidator = (value, minLength) => { | |
| return value.length >= minLength; | |
| } | |
| export default validate; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment