-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathservice_contract.go
59 lines (52 loc) · 1.37 KB
/
service_contract.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package sso
import (
"errors"
)
// SignUpRequest represents signup request
type SignUpRequest struct {
*User
DataOfBirth string `json:"dateOfBirth"`
Password string `json:"password"`
LandingPage string `json:"landingPage"`
}
// SignUpResponse represents signup response
type SignUpResponse struct {
*BaseResponse
*User
LandingPage string `json:"landingPage"`
}
// SignInRequest represents signin request
type SignInRequest struct {
Email string `json:"email"`
Password string `json:"password"`
RememberMe string `json:"rememberMe"`
LandingPage string `json:"landingPage"`
}
// SignInResponse represents signin response
type SignInResponse struct {
*BaseResponse
*User
LandingPage string `json:"landingPage"`
}
// BaseResponse represents base response
type BaseResponse struct {
Status string `json:"status"`
Error string `json:"error"`
ErrorSource string `json:"errorSource"`
}
// Validate check request all data if it is provided or valid.
func (r *SignUpRequest) Validate() (string, error) {
if r.User == nil || r.Name == "" {
return "name", errors.New("name was empty")
}
if r.User == nil || r.Email == "" {
return "email", errors.New("email was empty")
}
if r.Password == "" {
return "password", errors.New("password was empty")
}
if r.DataOfBirth == "" {
return "dataOfBirth", errors.New("data of birth was empty")
}
return "", nil
}