github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/contract_object.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 // ContractObject contract object 19 // swagger:model ContractObject 20 type ContractObject struct { 21 22 // abi version 23 // Required: true 24 AbiVersion Uint16 `json:"abi_version"` 25 26 // active 27 // Required: true 28 Active *bool `json:"active"` 29 30 // deposit 31 // Required: true 32 Deposit Uint64 `json:"deposit"` 33 34 // id 35 // Required: true 36 ID EncodedPubkey `json:"id"` 37 38 // owner id 39 // Required: true 40 OwnerID EncodedPubkey `json:"owner_id"` 41 42 // referrer ids 43 // Required: true 44 ReferrerIds []EncodedPubkey `json:"referrer_ids"` 45 46 // vm version 47 // Required: true 48 VMVersion Uint16 `json:"vm_version"` 49 } 50 51 // Validate validates this contract object 52 func (m *ContractObject) Validate(formats strfmt.Registry) error { 53 var res []error 54 55 if err := m.validateAbiVersion(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if err := m.validateActive(formats); err != nil { 60 res = append(res, err) 61 } 62 63 if err := m.validateDeposit(formats); err != nil { 64 res = append(res, err) 65 } 66 67 if err := m.validateID(formats); err != nil { 68 res = append(res, err) 69 } 70 71 if err := m.validateOwnerID(formats); err != nil { 72 res = append(res, err) 73 } 74 75 if err := m.validateReferrerIds(formats); err != nil { 76 res = append(res, err) 77 } 78 79 if err := m.validateVMVersion(formats); err != nil { 80 res = append(res, err) 81 } 82 83 if len(res) > 0 { 84 return errors.CompositeValidationError(res...) 85 } 86 return nil 87 } 88 89 func (m *ContractObject) validateAbiVersion(formats strfmt.Registry) error { 90 91 if err := m.AbiVersion.Validate(formats); err != nil { 92 if ve, ok := err.(*errors.Validation); ok { 93 return ve.ValidateName("abi_version") 94 } 95 return err 96 } 97 98 return nil 99 } 100 101 func (m *ContractObject) validateActive(formats strfmt.Registry) error { 102 103 if err := validate.Required("active", "body", m.Active); err != nil { 104 return err 105 } 106 107 return nil 108 } 109 110 func (m *ContractObject) validateDeposit(formats strfmt.Registry) error { 111 112 if err := m.Deposit.Validate(formats); err != nil { 113 if ve, ok := err.(*errors.Validation); ok { 114 return ve.ValidateName("deposit") 115 } 116 return err 117 } 118 119 return nil 120 } 121 122 func (m *ContractObject) validateID(formats strfmt.Registry) error { 123 124 if err := m.ID.Validate(formats); err != nil { 125 if ve, ok := err.(*errors.Validation); ok { 126 return ve.ValidateName("id") 127 } 128 return err 129 } 130 131 return nil 132 } 133 134 func (m *ContractObject) validateOwnerID(formats strfmt.Registry) error { 135 136 if err := m.OwnerID.Validate(formats); err != nil { 137 if ve, ok := err.(*errors.Validation); ok { 138 return ve.ValidateName("owner_id") 139 } 140 return err 141 } 142 143 return nil 144 } 145 146 func (m *ContractObject) validateReferrerIds(formats strfmt.Registry) error { 147 148 if err := validate.Required("referrer_ids", "body", m.ReferrerIds); err != nil { 149 return err 150 } 151 152 for i := 0; i < len(m.ReferrerIds); i++ { 153 154 if err := m.ReferrerIds[i].Validate(formats); err != nil { 155 if ve, ok := err.(*errors.Validation); ok { 156 return ve.ValidateName("referrer_ids" + "." + strconv.Itoa(i)) 157 } 158 return err 159 } 160 161 } 162 163 return nil 164 } 165 166 func (m *ContractObject) validateVMVersion(formats strfmt.Registry) error { 167 168 if err := m.VMVersion.Validate(formats); err != nil { 169 if ve, ok := err.(*errors.Validation); ok { 170 return ve.ValidateName("vm_version") 171 } 172 return err 173 } 174 175 return nil 176 } 177 178 // MarshalBinary interface implementation 179 func (m *ContractObject) MarshalBinary() ([]byte, error) { 180 if m == nil { 181 return nil, nil 182 } 183 return swag.WriteJSON(m) 184 } 185 186 // UnmarshalBinary interface implementation 187 func (m *ContractObject) UnmarshalBinary(b []byte) error { 188 var res ContractObject 189 if err := swag.ReadJSON(b, &res); err != nil { 190 return err 191 } 192 *m = res 193 return nil 194 }