add Block + Component, add TextComponent with min, max and regex validators and early NumberComponent
This commit is contained in:
14
internal/block/validation/required.go
Normal file
14
internal/block/validation/required.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package validation
|
||||
|
||||
import "fmt"
|
||||
|
||||
func Required() ComponentOption {
|
||||
return func(c *ComponentConfig) {
|
||||
c.Validators = append(c.Validators, func(value any) error {
|
||||
if value == nil || value == "" {
|
||||
return fmt.Errorf("field is required")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user