diff --git a/pkg/util/validation/errors.go b/pkg/util/validation/errors.go index 153a1ce94d1..e8f9b0783ff 100644 --- a/pkg/util/validation/errors.go +++ b/pkg/util/validation/errors.go @@ -172,7 +172,7 @@ func (list ErrorList) PrefixIndex(index int) ErrorList { return list.Prefix(fmt.Sprintf("[%d]", index)) } -// NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true +// NewErrorTypeMatcher returns an errors.Matcher that returns true // if the provided error is a Error and has the provided ErrorType. func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher { return func(err error) bool { @@ -183,18 +183,6 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher { } } -// NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true -// if the provided error is a Error and has a field with the provided -// prefix. -func NewValidationErrorFieldPrefixMatcher(prefix string) utilerrors.Matcher { - return func(err error) bool { - if e, ok := err.(*Error); ok { - return strings.HasPrefix(e.Field, prefix) - } - return false - } -} - // Filter removes items from the ErrorList that match the provided fns. func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList { err := utilerrors.FilterOut(utilerrors.NewAggregate(list), fns...) diff --git a/pkg/util/validation/errors_test.go b/pkg/util/validation/errors_test.go index a6258f4b21a..30631c477bc 100644 --- a/pkg/util/validation/errors_test.go +++ b/pkg/util/validation/errors_test.go @@ -105,18 +105,6 @@ func TestErrListFilter(t *testing.T) { if len(list.Filter(NewErrorTypeMatcher(ErrorTypeInvalid))) != 1 { t.Errorf("should filter") } - if len(list.Filter(NewValidationErrorFieldPrefixMatcher("test"))) != 1 { - t.Errorf("should filter") - } - if len(list.Filter(NewValidationErrorFieldPrefixMatcher("test."))) != 2 { - t.Errorf("should filter") - } - if len(list.Filter(NewValidationErrorFieldPrefixMatcher(""))) != 0 { - t.Errorf("should filter") - } - if len(list.Filter(NewValidationErrorFieldPrefixMatcher("field."), NewErrorTypeMatcher(ErrorTypeDuplicate))) != 1 { - t.Errorf("should filter") - } } func TestErrListPrefix(t *testing.T) {