MCPcopy Index your code
hub / github.com/go-playground/validator / RegisterStructValidationCtx

Method RegisterStructValidationCtx

validator_instance.go:263–276  ·  view source on GitHub ↗

RegisterStructValidationCtx registers a StructLevelFuncCtx against a number of types and allows passing of contextual validation information via context.Context. NOTE: - this method is not thread-safe it is intended that these all be registered prior to any validation

(fn StructLevelFuncCtx, types ...interface{})

Source from the content-addressed store, hash-verified

261// NOTE:
262// - this method is not thread-safe it is intended that these all be registered prior to any validation
263func (v *Validate) RegisterStructValidationCtx(fn StructLevelFuncCtx, types ...interface{}) {
264 if v.structLevelFuncs == nil {
265 v.structLevelFuncs = make(map[reflect.Type]StructLevelFuncCtx)
266 }
267
268 for _, t := range types {
269 tv := reflect.ValueOf(t)
270 if tv.Kind() == reflect.Ptr {
271 t = reflect.Indirect(tv).Interface()
272 }
273
274 v.structLevelFuncs[reflect.TypeOf(t)] = fn
275 }
276}
277
278// RegisterStructValidationMapRules registers validate map rules.
279// Be aware that map validation rules supersede those defined on a/the struct if present.

Callers 2

Calls 1

KindMethod · 0.65

Tested by 1