Created
April 27, 2019 04:48
-
-
Save mdmoin7/2ff10f103b56b57720f52b5ee9393e84 to your computer and use it in GitHub Desktop.
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
const errorMessages = { | |
required: () => 'This field is required', | |
pattern: () => 'Incorrect format', | |
minlength: (param) => `Min chars required is ${param.requiredLength}`, | |
maxlength: (param) => `Max chars allowed is ${param.requiredLength}` | |
}; | |
export const getErrorMsg = (err, errObj) => { | |
return errorMessages[err](errObj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment