payload.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Code generated by go-swagger; DO NOT EDIT.
  2. package models
  3. // This file was generated by the swagger tool.
  4. // Editing this file might prove futile when you re-run the swagger generate command
  5. import (
  6. "context"
  7. "github.com/go-openapi/errors"
  8. "github.com/go-openapi/strfmt"
  9. "github.com/go-openapi/swag"
  10. "github.com/go-openapi/validate"
  11. )
  12. // Payload payload
  13. //
  14. // swagger:model payload
  15. type Payload struct {
  16. // fuels
  17. // Required: true
  18. Fuels interface{} `json:"fuels"`
  19. // load
  20. // Required: true
  21. Load *float64 `json:"load"`
  22. // powerplants
  23. // Required: true
  24. Powerplants []interface{} `json:"powerplants"`
  25. }
  26. // Validate validates this payload
  27. func (m *Payload) Validate(formats strfmt.Registry) error {
  28. var res []error
  29. if err := m.validateFuels(formats); err != nil {
  30. res = append(res, err)
  31. }
  32. if err := m.validateLoad(formats); err != nil {
  33. res = append(res, err)
  34. }
  35. if err := m.validatePowerplants(formats); err != nil {
  36. res = append(res, err)
  37. }
  38. if len(res) > 0 {
  39. return errors.CompositeValidationError(res...)
  40. }
  41. return nil
  42. }
  43. func (m *Payload) validateFuels(formats strfmt.Registry) error {
  44. if m.Fuels == nil {
  45. return errors.Required("fuels", "body", nil)
  46. }
  47. return nil
  48. }
  49. func (m *Payload) validateLoad(formats strfmt.Registry) error {
  50. if err := validate.Required("load", "body", m.Load); err != nil {
  51. return err
  52. }
  53. return nil
  54. }
  55. func (m *Payload) validatePowerplants(formats strfmt.Registry) error {
  56. if err := validate.Required("powerplants", "body", m.Powerplants); err != nil {
  57. return err
  58. }
  59. return nil
  60. }
  61. // ContextValidate validates this payload based on context it is used
  62. func (m *Payload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
  63. return nil
  64. }
  65. // MarshalBinary interface implementation
  66. func (m *Payload) MarshalBinary() ([]byte, error) {
  67. if m == nil {
  68. return nil, nil
  69. }
  70. return swag.WriteJSON(m)
  71. }
  72. // UnmarshalBinary interface implementation
  73. func (m *Payload) UnmarshalBinary(b []byte) error {
  74. var res Payload
  75. if err := swag.ReadJSON(b, &res); err != nil {
  76. return err
  77. }
  78. *m = res
  79. return nil
  80. }