-
Notifications
You must be signed in to change notification settings - Fork 26
/
verification_request.go
197 lines (151 loc) · 4.46 KB
/
verification_request.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// VerificationRequest Request presents a verification request
//
// This request is used when an identity wants to verify an out-of-band communication
// channel such as an email address or a phone number.
//
// For more information head over to: https://www.ory.sh/docs/kratos/selfservice/flows/verify-email-account-activation
//
// swagger:model verificationRequest
type VerificationRequest struct {
// ExpiresAt is the time (UTC) when the request expires. If the user still wishes to verify the address,
// a new request has to be initiated.
// Format: date-time
ExpiresAt strfmt.DateTime `json:"expires_at,omitempty"`
// form
Form *Form `json:"form,omitempty"`
// id
// Format: uuid4
ID UUID `json:"id,omitempty"`
// IssuedAt is the time (UTC) when the request occurred.
// Format: date-time
IssuedAt strfmt.DateTime `json:"issued_at,omitempty"`
// messages
Messages Messages `json:"messages,omitempty"`
// RequestURL is the initial URL that was requested from ORY Kratos. It can be used
// to forward information contained in the URL's path or query for example.
RequestURL string `json:"request_url,omitempty"`
// Success, if true, implies that the request was completed successfully.
Success bool `json:"success,omitempty"`
// via
Via VerifiableAddressType `json:"via,omitempty"`
}
// Validate validates this verification request
func (m *VerificationRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateExpiresAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateForm(formats); err != nil {
res = append(res, err)
}
if err := m.validateID(formats); err != nil {
res = append(res, err)
}
if err := m.validateIssuedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateMessages(formats); err != nil {
res = append(res, err)
}
if err := m.validateVia(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *VerificationRequest) validateExpiresAt(formats strfmt.Registry) error {
if swag.IsZero(m.ExpiresAt) { // not required
return nil
}
if err := validate.FormatOf("expires_at", "body", "date-time", m.ExpiresAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *VerificationRequest) validateForm(formats strfmt.Registry) error {
if swag.IsZero(m.Form) { // not required
return nil
}
if m.Form != nil {
if err := m.Form.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("form")
}
return err
}
}
return nil
}
func (m *VerificationRequest) validateID(formats strfmt.Registry) error {
if swag.IsZero(m.ID) { // not required
return nil
}
if err := m.ID.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("id")
}
return err
}
return nil
}
func (m *VerificationRequest) validateIssuedAt(formats strfmt.Registry) error {
if swag.IsZero(m.IssuedAt) { // not required
return nil
}
if err := validate.FormatOf("issued_at", "body", "date-time", m.IssuedAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *VerificationRequest) validateMessages(formats strfmt.Registry) error {
if swag.IsZero(m.Messages) { // not required
return nil
}
if err := m.Messages.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("messages")
}
return err
}
return nil
}
func (m *VerificationRequest) validateVia(formats strfmt.Registry) error {
if swag.IsZero(m.Via) { // not required
return nil
}
if err := m.Via.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("via")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *VerificationRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *VerificationRequest) UnmarshalBinary(b []byte) error {
var res VerificationRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}