MCPcopy
hub / github.com/go-playground/validator / RegisterValidation

Method RegisterValidation

validator_instance.go:221–223  ·  view source on GitHub ↗

RegisterValidation adds a validation with the given tag NOTES: - if the key already exists, the previous validation function will be replaced. - this method is not thread-safe it is intended that these all be registered prior to any validation

(tag string, fn Func, callValidationEvenIfNull ...bool)

Source from the content-addressed store, hash-verified

219// - if the key already exists, the previous validation function will be replaced.
220// - this method is not thread-safe it is intended that these all be registered prior to any validation
221func (v *Validate) RegisterValidation(tag string, fn Func, callValidationEvenIfNull ...bool) error {
222 return v.RegisterValidationCtx(tag, wrapFunc(fn), callValidationEvenIfNull...)
223}
224
225// RegisterValidationCtx does the same as RegisterValidation on accepts a FuncCtx validation
226// allowing context.Context validation support.

Callers 11

TestNilValidatorFunction · 0.95
TestAddFunctionsFunction · 0.80
TestFieldLevelNameFunction · 0.80
TestKeysCustomValidationFunction · 0.80
TestGetTagFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
TestNotBlankFunction · 0.80

Calls 2

RegisterValidationCtxMethod · 0.95
wrapFuncFunction · 0.85

Tested by 9

TestNilValidatorFunction · 0.76
TestAddFunctionsFunction · 0.64
TestFieldLevelNameFunction · 0.64
TestKeysCustomValidationFunction · 0.64
TestGetTagFunction · 0.64
TestNotBlankFunction · 0.64