@@ -3,8 +3,8 @@ const Joi = require('joi');
3
3
4
4
const { handleSchemaValidationErrors } = require ( "../helpers" ) ;
5
5
6
- const emailRegexp = / ^ ( [ a - z 0 - 9 _ - ] + \. ) * [ a - z 0 - 9 _ - ] + @ [ a - z 0 - 9 _ - ] + ( \. [ a - z 0 - 9 _ - ] + ) * \. [ a - z ] { 2 , 6 } $ / ;
7
- // const emailRegexp = /^[\w.]+@[\w]+.[\w]+$/;
6
+ // const emailRegexp = /^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$/;
7
+ const emailRegexp = / ^ [ \w . ] + @ [ \w ] + .[ \w ] + $ / ;
8
8
9
9
const userShema = new Schema ( {
10
10
name : {
@@ -13,6 +13,8 @@ const userShema = new Schema({
13
13
} ,
14
14
email : {
15
15
type : String ,
16
+ minlength : 6 ,
17
+ maxLength : 63 ,
16
18
required : [ true , 'Email is required' ] ,
17
19
match : emailRegexp ,
18
20
unique : true ,
@@ -34,13 +36,13 @@ userShema.post("save", handleSchemaValidationErrors);
34
36
// ** Joi schemas ***************************************
35
37
const singupSchema = Joi . object ( {
36
38
name : Joi . string ( ) . required ( ) ,
37
- email : Joi . string ( ) . pattern ( emailRegexp ) . required ( ) ,
38
- password : Joi . string ( ) . min ( 6 ) . required ( ) ,
39
+ email : Joi . string ( ) . pattern ( emailRegexp ) . min ( 6 ) . required ( ) ,
40
+ password : Joi . string ( ) . min ( 6 ) . max ( 6 ) . required ( ) ,
39
41
repeat_password : Joi . string ( ) . required ( ) . valid ( Joi . ref ( 'password' ) ) ,
40
42
} )
41
43
42
44
const loginSchema = Joi . object ( {
43
- email : Joi . string ( ) . pattern ( emailRegexp ) . required ( ) ,
45
+ email : Joi . string ( ) . min ( 6 ) . max ( 6 ) . pattern ( emailRegexp ) . required ( ) ,
44
46
password : Joi . string ( ) . min ( 6 ) . required ( ) ,
45
47
} )
46
48
0 commit comments