mirror of
https://github.com/foomo/fender.git
synced 2026-06-28 22:00:03 +00:00
23 lines
275 B
Go
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
|
|
}
|