Files
fender/rule/valid.go
Kevin Franklin Kim 4495035afa feat: go 1.26.0
2026-02-26 22:51:04 +01:00

23 lines
275 B
Go

package rule
import (
"context"
)
const NameValid Name = "valid"
type (
Validator interface {
Valid() bool
}
ValidatorRule = Rule[Validator]
)
func Valid[T Validator](ctx context.Context, v T) error {
if !v.Valid() {
return NewError(NameValid)
}
return nil
}