github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/key_block_or_micro_block_header.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 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 ) 14 15 // KeyBlockOrMicroBlockHeader key block or micro block header 16 // swagger:model KeyBlockOrMicroBlockHeader 17 type KeyBlockOrMicroBlockHeader struct { 18 19 // key block 20 KeyBlock *KeyBlock `json:"key_block,omitempty"` 21 22 // micro block 23 MicroBlock *MicroBlockHeader `json:"micro_block,omitempty"` 24 } 25 26 // Validate validates this key block or micro block header 27 func (m *KeyBlockOrMicroBlockHeader) Validate(formats strfmt.Registry) error { 28 var res []error 29 30 if err := m.validateKeyBlock(formats); err != nil { 31 res = append(res, err) 32 } 33 34 if err := m.validateMicroBlock(formats); err != nil { 35 res = append(res, err) 36 } 37 38 if len(res) > 0 { 39 return errors.CompositeValidationError(res...) 40 } 41 return nil 42 } 43 44 func (m *KeyBlockOrMicroBlockHeader) validateKeyBlock(formats strfmt.Registry) error { 45 46 if swag.IsZero(m.KeyBlock) { // not required 47 return nil 48 } 49 50 if m.KeyBlock != nil { 51 if err := m.KeyBlock.Validate(formats); err != nil { 52 if ve, ok := err.(*errors.Validation); ok { 53 return ve.ValidateName("key_block") 54 } 55 return err 56 } 57 } 58 59 return nil 60 } 61 62 func (m *KeyBlockOrMicroBlockHeader) validateMicroBlock(formats strfmt.Registry) error { 63 64 if swag.IsZero(m.MicroBlock) { // not required 65 return nil 66 } 67 68 if m.MicroBlock != nil { 69 if err := m.MicroBlock.Validate(formats); err != nil { 70 if ve, ok := err.(*errors.Validation); ok { 71 return ve.ValidateName("micro_block") 72 } 73 return err 74 } 75 } 76 77 return nil 78 } 79 80 // MarshalBinary interface implementation 81 func (m *KeyBlockOrMicroBlockHeader) MarshalBinary() ([]byte, error) { 82 if m == nil { 83 return nil, nil 84 } 85 return swag.WriteJSON(m) 86 } 87 88 // UnmarshalBinary interface implementation 89 func (m *KeyBlockOrMicroBlockHeader) UnmarshalBinary(b []byte) error { 90 var res KeyBlockOrMicroBlockHeader 91 if err := swag.ReadJSON(b, &res); err != nil { 92 return err 93 } 94 *m = res 95 return nil 96 }