github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/ingredient_update.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package inventory_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 // IngredientUpdate Ingredient Update 18 // 19 // The fields of an ingredient that can be updated 20 // 21 // swagger:model ingredientUpdate 22 type IngredientUpdate struct { 23 24 // A concise summary of what this ingredient can be used for 25 // Required: true 26 Description *string `json:"description"` 27 28 // URL of the website about this ingredient (if any) 29 // Format: uri 30 Website strfmt.URI `json:"website,omitempty"` 31 } 32 33 // Validate validates this ingredient update 34 func (m *IngredientUpdate) 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 err := m.validateWebsite(formats); err != nil { 42 res = append(res, err) 43 } 44 45 if len(res) > 0 { 46 return errors.CompositeValidationError(res...) 47 } 48 return nil 49 } 50 51 func (m *IngredientUpdate) validateDescription(formats strfmt.Registry) error { 52 53 if err := validate.Required("description", "body", m.Description); err != nil { 54 return err 55 } 56 57 return nil 58 } 59 60 func (m *IngredientUpdate) validateWebsite(formats strfmt.Registry) error { 61 if swag.IsZero(m.Website) { // not required 62 return nil 63 } 64 65 if err := validate.FormatOf("website", "body", "uri", m.Website.String(), formats); err != nil { 66 return err 67 } 68 69 return nil 70 } 71 72 // ContextValidate validates this ingredient update based on context it is used 73 func (m *IngredientUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 74 return nil 75 } 76 77 // MarshalBinary interface implementation 78 func (m *IngredientUpdate) MarshalBinary() ([]byte, error) { 79 if m == nil { 80 return nil, nil 81 } 82 return swag.WriteJSON(m) 83 } 84 85 // UnmarshalBinary interface implementation 86 func (m *IngredientUpdate) UnmarshalBinary(b []byte) error { 87 var res IngredientUpdate 88 if err := swag.ReadJSON(b, &res); err != nil { 89 return err 90 } 91 *m = res 92 return nil 93 }