Last active
April 22, 2018 09:33
-
-
Save kettanaito/c08530c233134d2a77712120affbd72f to your computer and use it in GitHub Desktop.
React Advanced Form - Validation rules
This file contains 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
// src/app/validation-rules.js | |
import isEmail from 'validator/lib/isEmail'; | |
export default { | |
type: { | |
email: ({ value }) => isEmail(value), | |
password: { | |
capitalLetter: ({ value }) => /[A-Z]/.test(value), | |
oneNumber: ({ value }) => /[0-9]/.test(value), | |
minLength: ({ value }) => (value.length > 5) | |
} | |
}, | |
name: { | |
confirmPassword: { | |
matches: ({ value, get }) => { | |
return (value === get(['userPassword', 'value']); | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment