Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic error message #4

Closed
7dev3134 opened this issue Feb 11, 2019 · 2 comments · Fixed by #6
Closed

generic error message #4

7dev3134 opened this issue Feb 11, 2019 · 2 comments · Fixed by #6

Comments

@7dev3134
Copy link

the validation work but, when it fail the validation message is always the same

"message": "\"value\" must meet password complexity requirements",

is there a way to show a custom message to indicate what is need to change in the password ?
thanks

@andreavitiani
Copy link

I have the same question..
Joi.validate('aPassword123!', new PasswordComplexity(complexityOptions), (err, value) => { //... })

how can I implement the costume message in my job validation if my code is:

function validation(user) { const schema = Joi.object().keys({ name: Joi.string() .required() .min(5) .max(50), email: Joi.string() .required() .min(6) .max(255) .email(), password: new PasswordComplexity(complexityOptions).required() }); return Joi.validate(user, schema); }
?

For now the only solution I know is implementing a message in front end sign up page

@Mostalpha7
Copy link

You can do something like this;

password: JoiPasswordComplexity.string().minOfSpecialCharacters(2).minOfLowercase(2).minOfUppercase(2).minOfNumeric(2).messages({
"password.minOfUppercase": "my custom error message",
"password.minOfLowercase": "my custom error message",
"password.minOfSpecialCharacters": "my custom error message",
"password.minOfNumeric": "my custom error message",
}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants