15 lines
273 B
Go
15 lines
273 B
Go
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
|
|
})
|
|
}
|
|
}
|