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

Method VarWithKey

validator_instance.go:698–700  ·  view source on GitHub ↗

VarWithKey validates a single variable with a key to be included in the returned error using tag style validation eg. var s string validate.VarWithKey("email_address", s, "required,email") WARNING: a struct can be passed for validation eg. time.Time is a struct or if you have a custom type and have

(key string, field interface{}, tag string)

Source from the content-addressed store, hash-verified

696// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
697// validate Array, Slice and maps fields which may contain more than one error
698func (v *Validate) VarWithKey(key string, field interface{}, tag string) error {
699 return v.VarWithKeyCtx(context.Background(), key, field, tag)
700}
701
702// VarWithKeyCtx validates a single variable with a key to be included in the returned error using tag style validation
703// and allows passing of contextual validation information via context.Context.

Callers 2

TestValidate_VarWithKeyFunction · 0.80

Calls 1

VarWithKeyCtxMethod · 0.95

Tested by 2

TestValidate_VarWithKeyFunction · 0.64