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.
17 lines
286 B
17 lines
286 B
4 years ago
|
package validator
|
||
|
|
||
4 years ago
|
import "gitoa.ru/go-4devs/console/input/value"
|
||
4 years ago
|
|
||
4 years ago
|
func Enum(enum ...string) func(value.Value) error {
|
||
|
return func(in value.Value) error {
|
||
4 years ago
|
v := in.String()
|
||
|
for _, e := range enum {
|
||
|
if e == v {
|
||
|
return nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return NewError(ErrInvalid, v, enum)
|
||
|
}
|
||
|
}
|