github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/authentication/models/customer.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Customer customer 18 // 19 // swagger:model customer 20 type Customer struct { 21 22 // agent associated with this customer 23 AgentID int32 `json:"agentId,omitempty"` 24 25 // internal identifier of a customer 26 // Required: true 27 // Read Only: true 28 CustomerID int64 `json:"customerId"` 29 30 // fips code 31 // Required: true 32 // Min Length: 1 33 FipsCode *string `json:"fipsCode"` 34 35 // name 36 // Required: true 37 // Min Length: 1 38 Name *string `json:"name"` 39 40 // Lookup identifier to find a customer in the system 41 // Required: true 42 // Min Length: 11 43 Ssn *string `json:"ssn"` 44 45 // surname 46 // Required: true 47 // Min Length: 1 48 Surname *string `json:"surname"` 49 } 50 51 // Validate validates this customer 52 func (m *Customer) Validate(formats strfmt.Registry) error { 53 var res []error 54 55 if err := m.validateCustomerID(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if err := m.validateFipsCode(formats); err != nil { 60 res = append(res, err) 61 } 62 63 if err := m.validateName(formats); err != nil { 64 res = append(res, err) 65 } 66 67 if err := m.validateSsn(formats); err != nil { 68 res = append(res, err) 69 } 70 71 if err := m.validateSurname(formats); err != nil { 72 res = append(res, err) 73 } 74 75 if len(res) > 0 { 76 return errors.CompositeValidationError(res...) 77 } 78 return nil 79 } 80 81 func (m *Customer) validateCustomerID(formats strfmt.Registry) error { 82 83 if err := validate.Required("customerId", "body", int64(m.CustomerID)); err != nil { 84 return err 85 } 86 87 return nil 88 } 89 90 func (m *Customer) validateFipsCode(formats strfmt.Registry) error { 91 92 if err := validate.Required("fipsCode", "body", m.FipsCode); err != nil { 93 return err 94 } 95 96 if err := validate.MinLength("fipsCode", "body", *m.FipsCode, 1); err != nil { 97 return err 98 } 99 100 return nil 101 } 102 103 func (m *Customer) validateName(formats strfmt.Registry) error { 104 105 if err := validate.Required("name", "body", m.Name); err != nil { 106 return err 107 } 108 109 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 110 return err 111 } 112 113 return nil 114 } 115 116 func (m *Customer) validateSsn(formats strfmt.Registry) error { 117 118 if err := validate.Required("ssn", "body", m.Ssn); err != nil { 119 return err 120 } 121 122 if err := validate.MinLength("ssn", "body", *m.Ssn, 11); err != nil { 123 return err 124 } 125 126 return nil 127 } 128 129 func (m *Customer) validateSurname(formats strfmt.Registry) error { 130 131 if err := validate.Required("surname", "body", m.Surname); err != nil { 132 return err 133 } 134 135 if err := validate.MinLength("surname", "body", *m.Surname, 1); err != nil { 136 return err 137 } 138 139 return nil 140 } 141 142 // ContextValidate validate this customer based on the context it is used 143 func (m *Customer) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 144 var res []error 145 146 if err := m.contextValidateCustomerID(ctx, formats); err != nil { 147 res = append(res, err) 148 } 149 150 if len(res) > 0 { 151 return errors.CompositeValidationError(res...) 152 } 153 return nil 154 } 155 156 func (m *Customer) contextValidateCustomerID(ctx context.Context, formats strfmt.Registry) error { 157 158 if err := validate.ReadOnly(ctx, "customerId", "body", int64(m.CustomerID)); err != nil { 159 return err 160 } 161 162 return nil 163 } 164 165 // MarshalBinary interface implementation 166 func (m *Customer) MarshalBinary() ([]byte, error) { 167 if m == nil { 168 return nil, nil 169 } 170 return swag.WriteJSON(m) 171 } 172 173 // UnmarshalBinary interface implementation 174 func (m *Customer) UnmarshalBinary(b []byte) error { 175 var res Customer 176 if err := swag.ReadJSON(b, &res); err != nil { 177 return err 178 } 179 *m = res 180 return nil 181 }