MCPcopy
hub / github.com/gin-gonic/gin / TestValidateAndModifyStruct

Function TestValidateAndModifyStruct

binding/validate_test.go:205–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func TestValidateAndModifyStruct(t *testing.T) {
206 // This validates that pointers to structs are passed to the validator
207 // giving us the ability to modify the struct being validated.
208 engine, ok := Validator.Engine().(*validator.Validate)
209 assert.True(t, ok)
210
211 engine.RegisterStructValidation(toZero, structModifyValidation{})
212
213 s := structModifyValidation{Integer: 1}
214 errs := validate(&s)
215
216 require.NoError(t, errs)
217 assert.Equal(t, structModifyValidation{Integer: 0}, s)
218}
219
220// structCustomValidation is a helper struct we use to check that
221// custom validation can be registered on it.

Callers

nothing calls this directly

Calls 2

validateFunction · 0.70
EngineMethod · 0.65

Tested by

no test coverage detected