-
Notifications
You must be signed in to change notification settings - Fork 20
/
field.go
30 lines (23 loc) · 970 Bytes
/
field.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package types
import (
"github.com/nyaruka/goflow/assets"
)
// Field is a JSON serializable implementation of a field asset
type Field struct {
UUID_ assets.FieldUUID `json:"uuid"`
Key_ string `json:"key" validate:"required"`
Name_ string `json:"name"`
Type_ assets.FieldType `json:"type" validate:"required"`
}
// NewField creates a new field from the passed in key, name and type
func NewField(uuid assets.FieldUUID, key string, name string, valueType assets.FieldType) assets.Field {
return &Field{UUID_: uuid, Key_: key, Name_: name, Type_: valueType}
}
// UUID returns the UUID of this field
func (f *Field) UUID() assets.FieldUUID { return f.UUID_ }
// Key returns the unique key of the field
func (f *Field) Key() string { return f.Key_ }
// Name returns the name of the field
func (f *Field) Name() string { return f.Name_ }
// Type returns the value type of the field
func (f *Field) Type() assets.FieldType { return f.Type_ }