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
This commit is part of merge request !1116. Comments created here will be created in the context of that merge request.
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
func contains(array []*validate.Violation, err *validate.Violation) bool { func contains(array []*validate.Violation, err *validate.Violation) bool {
for _, v := range array { 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 return true
} }
} }
...@@ -17,6 +17,20 @@ func contains(array []*validate.Violation, err *validate.Violation) bool { ...@@ -17,6 +17,20 @@ func contains(array []*validate.Violation, err *validate.Violation) bool {
return false 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) { func assertValidationErrors(t *testing.T, err error, expectedValidationErrors []*validate.Violation) {
st := status.Convert(err) st := status.Convert(err)
errDetails := st.Details() errDetails := st.Details()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment