github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list-strict/models/item.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 // Item item 16 // 17 // swagger:model item 18 type Item struct { 19 20 // completed 21 Completed bool `json:"completed,omitempty"` 22 23 // description 24 // Required: true 25 // Min Length: 1 26 Description *string `json:"description"` 27 28 // id 29 // Read Only: true 30 ID int64 `json:"id,omitempty"` 31 } 32 33 // Validate validates this item 34 func (m *Item) Validate(formats strfmt.Registry) error { 35 var res []error 36 37 if err := m.validateDescription(formats); err != nil { 38 res = append(res, err) 39 } 40 41 if len(res) > 0 { 42 return errors.CompositeValidationError(res...) 43 } 44 return nil 45 } 46 47 func (m *Item) validateDescription(formats strfmt.Registry) error { 48 49 if err := validate.Required("description", "body", m.Description); err != nil { 50 return err 51 } 52 53 if err := validate.MinLength("description", "body", string(*m.Description), 1); err != nil { 54 return err 55 } 56 57 return nil 58 } 59 60 // MarshalBinary interface implementation 61 func (m *Item) 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 *Item) UnmarshalBinary(b []byte) error { 70 var res Item 71 if err := swag.ReadJSON(b, &res); err != nil { 72 return err 73 } 74 *m = res 75 return nil 76 }