-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_create_req.go
35 lines (32 loc) · 1002 Bytes
/
user_create_req.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package usermodel
import "github.com/prakash-p-3121/errorlib"
type UserCreateReq struct {
FirstName *string `json:"first-name"`
LastName *string `json:"last-name"`
EmailID *string `json:"email-id"`
CountryCode *string `json:"country-code"`
PhoneNumberStr *string `json:"phone-number"`
Password *string `json:"password"`
}
func (req *UserCreateReq) Validate() errorlib.AppError {
if req.FirstName == nil {
return errorlib.NewBadReqError("first-name-null")
}
if req.LastName == nil {
return errorlib.NewBadReqError("last-name-null")
}
if req.EmailID == nil {
return errorlib.NewBadReqError("email-id-null")
}
if req.CountryCode == nil {
return errorlib.NewBadReqError("country-code-null")
}
if req.PhoneNumberStr == nil {
return errorlib.NewBadReqError("phone-number-null")
}
if req.Password == nil {
return errorlib.NewBadReqError("password-null")
}
/* Add new validations like email id regex check, country code check etc.. */
return nil
}