You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
292 B

package validator
import "gitoa.ru/go-4devs/console/input/value"
func Enum(enum ...string) func(value.Value) error {
return func(in value.Value) error {
val := in.String()
for _, e := range enum {
if e == val {
return nil
}
}
return NewError(ErrInvalid, val, enum)
}
}