Commit bca3780b authored by Tim Hockin's avatar Tim Hockin

Remove unused matcher

parent 48b49a5c
......@@ -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...)
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment