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)
| 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 |
| 698 | func (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. |