// Code generated by go-swagger; DO NOT EDIT. package models // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "context" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Payload payload // // swagger:model payload type Payload struct { // fuels // Required: true Fuels interface{} `json:"fuels"` // load // Required: true Load *float64 `json:"load"` // powerplants // Required: true Powerplants []*Powerplant `json:"powerplants"` } // Validate validates this payload func (m *Payload) Validate(formats strfmt.Registry) error { var res []error if err := m.validateFuels(formats); err != nil { res = append(res, err) } if err := m.validateLoad(formats); err != nil { res = append(res, err) } if err := m.validatePowerplants(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Payload) validateFuels(formats strfmt.Registry) error { if m.Fuels == nil { return errors.Required("fuels", "body", nil) } return nil } func (m *Payload) validateLoad(formats strfmt.Registry) error { if err := validate.Required("load", "body", m.Load); err != nil { return err } return nil } func (m *Payload) validatePowerplants(formats strfmt.Registry) error { if err := validate.Required("powerplants", "body", m.Powerplants); err != nil { return err } for i := 0; i < len(m.Powerplants); i++ { if swag.IsZero(m.Powerplants[i]) { // not required continue } if m.Powerplants[i] != nil { if err := m.Powerplants[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("powerplants" + "." + strconv.Itoa(i)) } return err } } } return nil } // ContextValidate validate this payload based on the context it is used func (m *Payload) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidatePowerplants(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Payload) contextValidatePowerplants(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Powerplants); i++ { if m.Powerplants[i] != nil { if err := m.Powerplants[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("powerplants" + "." + strconv.Itoa(i)) } return err } } } return nil } // MarshalBinary interface implementation func (m *Payload) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Payload) UnmarshalBinary(b []byte) error { var res Payload if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }