added the dot (.) username rules (#787)

This commit is contained in:
Marco Beretta 2023-08-11 19:02:52 +02:00 committed by GitHub
parent 91d32fa4f6
commit 1aa4b34dc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -25,7 +25,7 @@ const userSchema = mongoose.Schema(
type: String, type: String,
lowercase: true, lowercase: true,
required: [true, 'can\'t be blank'], required: [true, 'can\'t be blank'],
match: [/^[a-zA-Z0-9_-]+$/, 'is invalid'], match: [/^[a-zA-Z0-9_.-]+$/, 'is invalid'],
index: true, index: true,
}, },
email: { email: {
@ -177,7 +177,7 @@ module.exports.validateUser = (user) => {
username: Joi.string() username: Joi.string()
.min(2) .min(2)
.max(80) .max(80)
.regex(/^[a-zA-Z0-9_-]+$/) .regex(/^[a-zA-Z0-9_.-]+$/)
.required(), .required(),
password: Joi.string().min(8).max(128).allow('').allow(null), password: Joi.string().min(8).max(128).allow('').allow(null),
}; };

View file

@ -11,7 +11,7 @@ const registerSchema = Joi.object().keys({
.trim() .trim()
.min(2) .min(2)
.max(20) .max(20)
.regex(/^[a-zA-Z0-9_-]+$/) .regex(/^[a-zA-Z0-9_.-]+$/)
.required(), .required(),
email: Joi.string().trim().email().required(), email: Joi.string().trim().email().required(),
password: Joi.string().trim().min(8).max(128).required(), password: Joi.string().trim().min(8).max(128).required(),