| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- // 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
- }
|