add Block + Component, add TextComponent with min, max and regex validators and early NumberComponent
This commit is contained in:
27
internal/block/component.go
Normal file
27
internal/block/component.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package block
|
||||
|
||||
import (
|
||||
"blocky/internal/block/validation"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type ComponentType int8
|
||||
|
||||
const (
|
||||
_ ComponentType = iota
|
||||
TextComponentType
|
||||
NumberComponentType
|
||||
Date
|
||||
)
|
||||
|
||||
type Component interface {
|
||||
Type() ComponentType
|
||||
Identifier() string
|
||||
Name() string
|
||||
NewInstance() ComponentInstance
|
||||
Validators() []validation.Validator
|
||||
}
|
||||
|
||||
type ComponentInstance interface {
|
||||
FromJSON(component Component, data json.RawMessage) error
|
||||
}
|
||||
Reference in New Issue
Block a user