github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list-strict/models/error.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 "github.com/go-openapi/errors" 10 "github.com/go-openapi/strfmt" 11 "github.com/go-openapi/swag" 12 "github.com/go-openapi/validate" 13 ) 14 15 // Error error 16 // 17 // swagger:model error 18 type Error struct { 19 20 // code 21 Code int64 `json:"code,omitempty"` 22 23 // message 24 // Required: true 25 Message *string `json:"message"` 26 } 27 28 // Validate validates this error 29 func (m *Error) Validate(formats strfmt.Registry) error { 30 var res []error 31 32 if err := m.validateMessage(formats); err != nil { 33 res = append(res, err) 34 } 35 36 if len(res) > 0 { 37 return errors.CompositeValidationError(res...) 38 } 39 return nil 40 } 41 42 func (m *Error) validateMessage(formats strfmt.Registry) error { 43 44 if err := validate.Required("message", "body", m.Message); err != nil { 45 return err 46 } 47 48 return nil 49 } 50 51 // MarshalBinary interface implementation 52 func (m *Error) MarshalBinary() ([]byte, error) { 53 if m == nil { 54 return nil, nil 55 } 56 return swag.WriteJSON(m) 57 } 58 59 // UnmarshalBinary interface implementation 60 func (m *Error) UnmarshalBinary(b []byte) error { 61 var res Error 62 if err := swag.ReadJSON(b, &res); err != nil { 63 return err 64 } 65 *m = res 66 return nil 67 }