mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-10 17:04:49 +08:00
better erorr message when username contains profanity
This commit is contained in:
parent
0f589b0e5b
commit
682216588d
1 changed files with 12 additions and 4 deletions
|
@ -68,13 +68,21 @@ const usernameValidation = joi
|
|||
.string()
|
||||
.required()
|
||||
.custom((value, helpers) => {
|
||||
return isUsernameValid(value)
|
||||
? value
|
||||
: helpers.error("string.pattern.base");
|
||||
if (containsProfanity(value)) {
|
||||
return helpers.error("string.profanity");
|
||||
}
|
||||
|
||||
if (!isUsernameValid(value)) {
|
||||
return helpers.error("string.pattern.base");
|
||||
}
|
||||
|
||||
return value;
|
||||
})
|
||||
.messages({
|
||||
"string.profanity":
|
||||
"The username contains profanity. If you believe this is a mistake, please contact us ",
|
||||
"string.pattern.base":
|
||||
"Username invalid. Name cannot use special characters or contain more than 16 characters. Can include _ . and -",
|
||||
"Username invalid. Name cannot use special characters or contain more than 16 characters. Can include _ . and - ",
|
||||
});
|
||||
|
||||
const languageSchema = joi.string().min(1).required();
|
||||
|
|
Loading…
Reference in a new issue