github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/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 // TTL TTL 19 // swagger:model TTL 20 type TTL struct { 21 22 // type 23 // Required: true 24 // Enum: [delta block] 25 Type *string `json:"type"` 26 27 // value 28 // Required: true 29 Value Uint64 `json:"value"` 30 } 31 32 // Validate validates this TTL 33 func (m *TTL) 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 ttlTypeTypePropEnum []interface{} 51 52 func init() { 53 var res []string 54 if err := json.Unmarshal([]byte(`["delta","block"]`), &res); err != nil { 55 panic(err) 56 } 57 for _, v := range res { 58 ttlTypeTypePropEnum = append(ttlTypeTypePropEnum, v) 59 } 60 } 61 62 const ( 63 64 // TTLTypeDelta captures enum value "delta" 65 TTLTypeDelta string = "delta" 66 67 // TTLTypeBlock captures enum value "block" 68 TTLTypeBlock string = "block" 69 ) 70 71 // prop value enum 72 func (m *TTL) validateTypeEnum(path, location string, value string) error { 73 if err := validate.Enum(path, location, value, ttlTypeTypePropEnum); err != nil { 74 return err 75 } 76 return nil 77 } 78 79 func (m *TTL) validateType(formats strfmt.Registry) error { 80 81 if err := validate.Required("type", "body", m.Type); err != nil { 82 return err 83 } 84 85 // value enum 86 if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { 87 return err 88 } 89 90 return nil 91 } 92 93 func (m *TTL) validateValue(formats strfmt.Registry) error { 94 95 if err := m.Value.Validate(formats); err != nil { 96 if ve, ok := err.(*errors.Validation); ok { 97 return ve.ValidateName("value") 98 } 99 return err 100 } 101 102 return nil 103 } 104 105 // MarshalBinary interface implementation 106 func (m *TTL) MarshalBinary() ([]byte, error) { 107 if m == nil { 108 return nil, nil 109 } 110 return swag.WriteJSON(m) 111 } 112 113 // UnmarshalBinary interface implementation 114 func (m *TTL) UnmarshalBinary(b []byte) error { 115 var res TTL 116 if err := swag.ReadJSON(b, &res); err != nil { 117 return err 118 } 119 *m = res 120 return nil 121 }