Skip to content
Snippets Groups Projects
Commit 8eee2451 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

fix use of deprecated field of struct, needs helper because non comparable impl.MessageState

parent c44e2bdf
No related branches found
No related tags found
No related merge requests found
Pipeline #239084 passed
......@@ -9,7 +9,7 @@ import (
func contains(array []*validate.Violation, err *validate.Violation) bool {
for _, v := range array {
if *v.FieldPath == *err.FieldPath && *v.ConstraintId == *err.ConstraintId && *v.Message == *err.Message {
if isEqualFieldPaths(v.Field, err.Field) && *v.ConstraintId == *err.ConstraintId && *v.Message == *err.Message {
return true
}
}
......@@ -17,6 +17,20 @@ func contains(array []*validate.Violation, err *validate.Violation) bool {
return false
}
func isEqualFieldPaths(violationFieldPath, errFieldPath *validate.FieldPath) bool {
if len(violationFieldPath.GetElements()) != len(errFieldPath.GetElements()) {
return false
}
for i, elem := range violationFieldPath.GetElements() {
if elem != errFieldPath.GetElements()[i] {
return false
}
}
return true
}
func assertValidationErrors(t *testing.T, err error, expectedValidationErrors []*validate.Violation) {
st := status.Convert(err)
errDetails := st.Details()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment