Created
December 26, 2019 11:55
-
-
Save tofazzal-shuvo/6ffe2790e37e8dae8d914c986d6529ed 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
| import validator from "validator"; | |
| export default (name, value, required) => { | |
| if (!value && required) { | |
| if (name === "email") return { [name]: "Email can't be empty!" }; | |
| else if (name === "password") return { [name]: "Password can't be empty!" }; | |
| } else { | |
| if (name === "password" && value.length < 6) | |
| return { [name]: "Password can't be less then 6 character!" }; | |
| else if (name === "email" && !validator.isEmail(value)) | |
| return { [name]: "Email is badly formatted!" }; | |
| return { [name]: "" }; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment