github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/error_response.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package modelscapi 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 // ErrorResponse error response 18 // 19 // error response return by the API 20 // 21 // swagger:model ErrorResponse 22 type ErrorResponse struct { 23 24 // more detail on individual errors 25 Errors string `json:"errors,omitempty"` 26 27 // Error message 28 // Required: true 29 Message *string `json:"message"` 30 } 31 32 // Validate validates this error response 33 func (m *ErrorResponse) Validate(formats strfmt.Registry) error { 34 var res []error 35 36 if err := m.validateMessage(formats); err != nil { 37 res = append(res, err) 38 } 39 40 if len(res) > 0 { 41 return errors.CompositeValidationError(res...) 42 } 43 return nil 44 } 45 46 func (m *ErrorResponse) validateMessage(formats strfmt.Registry) error { 47 48 if err := validate.Required("message", "body", m.Message); err != nil { 49 return err 50 } 51 52 return nil 53 } 54 55 // ContextValidate validates this error response based on context it is used 56 func (m *ErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 57 return nil 58 } 59 60 // MarshalBinary interface implementation 61 func (m *ErrorResponse) MarshalBinary() ([]byte, error) { 62 if m == nil { 63 return nil, nil 64 } 65 return swag.WriteJSON(m) 66 } 67 68 // UnmarshalBinary interface implementation 69 func (m *ErrorResponse) UnmarshalBinary(b []byte) error { 70 var res ErrorResponse 71 if err := swag.ReadJSON(b, &res); err != nil { 72 return err 73 } 74 *m = res 75 return nil 76 }