40 lines
560 B
Go
40 lines
560 B
Go
package flow
|
|
|
|
type Type string
|
|
|
|
const (
|
|
TypeString Type = "string"
|
|
)
|
|
|
|
func (t Type) IsValid() bool {
|
|
switch t {
|
|
case TypeString:
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
type SchemaItem struct {
|
|
Type Type `json:"type"`
|
|
Name string `json:"name"`
|
|
Required bool `json:"required"`
|
|
}
|
|
|
|
type Schema []SchemaItem
|
|
|
|
type Schemer interface {
|
|
FlowSchema() Schema
|
|
}
|
|
|
|
func NewSchema(items ...SchemaItem) Schema {
|
|
return items
|
|
}
|
|
|
|
func RequiredString(name string) SchemaItem {
|
|
return SchemaItem{
|
|
Type: TypeString,
|
|
Name: name,
|
|
Required: true,
|
|
}
|
|
}
|