github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/relative_ttl.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 "encoding/json" 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 // RelativeTTL relative TTL 19 // swagger:model RelativeTTL 20 type RelativeTTL struct { 21 22 // type 23 // Required: true 24 // Enum: [delta] 25 Type *string `json:"type"` 26 27 // value 28 // Required: true 29 Value *uint64 `json:"value"` 30 } 31 32 // Validate validates this relative TTL 33 func (m *RelativeTTL) Validate(formats strfmt.Registry) error { 34 var res []error 35 36 if err := m.validateType(formats); err != nil { 37 res = append(res, err) 38 } 39 40 if err := m.validateValue(formats); err != nil { 41 res = append(res, err) 42 } 43 44 if len(res) > 0 { 45 return errors.CompositeValidationError(res...) 46 } 47 return nil 48 } 49 50 var relativeTtlTypeTypePropEnum []interface{} 51 52 func init() { 53 var res []string 54 if err := json.Unmarshal([]byte(`["delta"]`), &res); err != nil { 55 panic(err) 56 } 57 for _, v := range res { 58 relativeTtlTypeTypePropEnum = append(relativeTtlTypeTypePropEnum, v) 59 } 60 } 61 62 const ( 63 64 // RelativeTTLTypeDelta captures enum value "delta" 65 RelativeTTLTypeDelta string = "delta" 66 ) 67 68 // prop value enum 69 func (m *RelativeTTL) validateTypeEnum(path, location string, value string) error { 70 if err := validate.Enum(path, location, value, relativeTtlTypeTypePropEnum); err != nil { 71 return err 72 } 73 return nil 74 } 75 76 func (m *RelativeTTL) validateType(formats strfmt.Registry) error { 77 78 if err := validate.Required("type", "body", m.Type); err != nil { 79 return err 80 } 81 82 // value enum 83 if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { 84 return err 85 } 86 87 return nil 88 } 89 90 func (m *RelativeTTL) validateValue(formats strfmt.Registry) error { 91 92 if err := validate.Required("value", "body", m.Value); err != nil { 93 return err 94 } 95 96 return nil 97 } 98 99 // MarshalBinary interface implementation 100 func (m *RelativeTTL) MarshalBinary() ([]byte, error) { 101 if m == nil { 102 return nil, nil 103 } 104 return swag.WriteJSON(m) 105 } 106 107 // UnmarshalBinary interface implementation 108 func (m *RelativeTTL) UnmarshalBinary(b []byte) error { 109 var res RelativeTTL 110 if err := swag.ReadJSON(b, &res); err != nil { 111 return err 112 } 113 *m = res 114 return nil 115 }