MCPcopy Create free account
hub / github.com/go-playground/validator / AssertError

Function AssertError

validator_test.go:118–137  ·  view source on GitHub ↗
(t *testing.T, err error, nsKey, structNsKey, field, structField, expectedTag string)

Source from the content-addressed store, hash-verified

116}
117
118func AssertError(t *testing.T, err error, nsKey, structNsKey, field, structField, expectedTag string) {
119 errs := err.(ValidationErrors)
120
121 found := false
122 var fe FieldError
123
124 for i := 0; i < len(errs); i++ {
125 if errs[i].Namespace() == nsKey && errs[i].StructNamespace() == structNsKey {
126 found = true
127 fe = errs[i]
128 break
129 }
130 }
131
132 EqualSkip(t, 2, found, true)
133 NotEqualSkip(t, 2, fe, nil)
134 EqualSkip(t, 2, fe.Field(), field)
135 EqualSkip(t, 2, fe.StructField(), structField)
136 EqualSkip(t, 2, fe.Tag(), expectedTag)
137}
138
139func AssertDeepError(t *testing.T, err error, nsKey, structNsKey, field, structField, expectedTag, actualTag string) {
140 errs := err.(ValidationErrors)

Calls 5

FieldMethod · 0.95
StructFieldMethod · 0.95
TagMethod · 0.95
NamespaceMethod · 0.65
StructNamespaceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…