github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/name_entry.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 // NameEntry name entry 19 // swagger:model NameEntry 20 type NameEntry struct { 21 22 // id 23 // Required: true 24 ID EncodedValue `json:"id"` 25 26 // pointers 27 // Required: true 28 Pointers []*NamePointer `json:"pointers"` 29 30 // ttl 31 // Required: true 32 TTL Uint64 `json:"ttl"` 33 } 34 35 // Validate validates this name entry 36 func (m *NameEntry) Validate(formats strfmt.Registry) error { 37 var res []error 38 39 if err := m.validateID(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if err := m.validatePointers(formats); err != nil { 44 res = append(res, err) 45 } 46 47 if err := m.validateTTL(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if len(res) > 0 { 52 return errors.CompositeValidationError(res...) 53 } 54 return nil 55 } 56 57 func (m *NameEntry) validateID(formats strfmt.Registry) error { 58 59 if err := m.ID.Validate(formats); err != nil { 60 if ve, ok := err.(*errors.Validation); ok { 61 return ve.ValidateName("id") 62 } 63 return err 64 } 65 66 return nil 67 } 68 69 func (m *NameEntry) validatePointers(formats strfmt.Registry) error { 70 71 if err := validate.Required("pointers", "body", m.Pointers); err != nil { 72 return err 73 } 74 75 for i := 0; i < len(m.Pointers); i++ { 76 if swag.IsZero(m.Pointers[i]) { // not required 77 continue 78 } 79 80 if m.Pointers[i] != nil { 81 if err := m.Pointers[i].Validate(formats); err != nil { 82 if ve, ok := err.(*errors.Validation); ok { 83 return ve.ValidateName("pointers" + "." + strconv.Itoa(i)) 84 } 85 return err 86 } 87 } 88 89 } 90 91 return nil 92 } 93 94 func (m *NameEntry) validateTTL(formats strfmt.Registry) error { 95 96 if err := m.TTL.Validate(formats); err != nil { 97 if ve, ok := err.(*errors.Validation); ok { 98 return ve.ValidateName("ttl") 99 } 100 return err 101 } 102 103 return nil 104 } 105 106 // MarshalBinary interface implementation 107 func (m *NameEntry) MarshalBinary() ([]byte, error) { 108 if m == nil { 109 return nil, nil 110 } 111 return swag.WriteJSON(m) 112 } 113 114 // UnmarshalBinary interface implementation 115 func (m *NameEntry) UnmarshalBinary(b []byte) error { 116 var res NameEntry 117 if err := swag.ReadJSON(b, &res); err != nil { 118 return err 119 } 120 *m = res 121 return nil 122 }