github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/generation.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 "strconv" 10 11 strfmt "github.com/go-openapi/strfmt" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Generation generation 19 // swagger:model Generation 20 type Generation struct { 21 22 // key block 23 // Required: true 24 KeyBlock *KeyBlock `json:"key_block"` 25 26 // micro blocks 27 // Required: true 28 MicroBlocks []EncodedPubkey `json:"micro_blocks"` 29 } 30 31 // Validate validates this generation 32 func (m *Generation) Validate(formats strfmt.Registry) error { 33 var res []error 34 35 if err := m.validateKeyBlock(formats); err != nil { 36 res = append(res, err) 37 } 38 39 if err := m.validateMicroBlocks(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if len(res) > 0 { 44 return errors.CompositeValidationError(res...) 45 } 46 return nil 47 } 48 49 func (m *Generation) validateKeyBlock(formats strfmt.Registry) error { 50 51 if err := validate.Required("key_block", "body", m.KeyBlock); err != nil { 52 return err 53 } 54 55 if m.KeyBlock != nil { 56 if err := m.KeyBlock.Validate(formats); err != nil { 57 if ve, ok := err.(*errors.Validation); ok { 58 return ve.ValidateName("key_block") 59 } 60 return err 61 } 62 } 63 64 return nil 65 } 66 67 func (m *Generation) validateMicroBlocks(formats strfmt.Registry) error { 68 69 if err := validate.Required("micro_blocks", "body", m.MicroBlocks); err != nil { 70 return err 71 } 72 73 for i := 0; i < len(m.MicroBlocks); i++ { 74 75 if err := m.MicroBlocks[i].Validate(formats); err != nil { 76 if ve, ok := err.(*errors.Validation); ok { 77 return ve.ValidateName("micro_blocks" + "." + strconv.Itoa(i)) 78 } 79 return err 80 } 81 82 } 83 84 return nil 85 } 86 87 // MarshalBinary interface implementation 88 func (m *Generation) MarshalBinary() ([]byte, error) { 89 if m == nil { 90 return nil, nil 91 } 92 return swag.WriteJSON(m) 93 } 94 95 // UnmarshalBinary interface implementation 96 func (m *Generation) UnmarshalBinary(b []byte) error { 97 var res Generation 98 if err := swag.ReadJSON(b, &res); err != nil { 99 return err 100 } 101 *m = res 102 return nil 103 }