first commit

This commit is contained in:
2020-10-25 10:00:59 +03:00
commit 0bd6f67397
80 changed files with 4741 additions and 0 deletions

24
validator/enum_test.go Normal file
View File

@@ -0,0 +1,24 @@
package validator_test
import (
"errors"
"testing"
"gitoa.ru/go-4devs/console/input/value"
"gitoa.ru/go-4devs/console/validator"
)
func TestEnum(t *testing.T) {
validValue := value.New("valid")
invalidValue := value.New("invalid")
enum := validator.Enum("valid", "other", "three")
if err := enum(validValue); err != nil {
t.Errorf("expected valid value got err:%s", err)
}
if err := enum(invalidValue); !errors.Is(err, validator.ErrInvalid) {
t.Errorf("expected err:%s, got: %s", validator.ErrInvalid, err)
}
}