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

Method Var

validator_instance.go:594–596  ·  view source on GitHub ↗

Var validates a single variable using tag style validation. eg. var i int validate.Var(i, "gt=1,lt=10") WARNING: a struct can be passed for validation eg. time.Time is a struct or if you have a custom type and have registered a custom type handler, so must allow it; however unforeseen validations w

(field interface{}, tag string)

Source from the content-addressed store, hash-verified

592// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
593// validate Array, Slice and maps fields which may contain more than one error
594func (v *Validate) Var(field interface{}, tag string) error {
595 return v.VarCtx(context.Background(), field, tag)
596}
597
598// VarCtx validates a single variable using tag style validation and allows passing of contextual
599// validation information via context.Context.

Callers 15

TestNilValidatorFunction · 0.95
TestAliasTagsFunction · 0.80
TestSQLValue2ValidationFunction · 0.80
TestSQLValueValidationFunction · 0.80
TestMACValidationFunction · 0.80
TestIPValidationFunction · 0.80
TestIPv6ValidationFunction · 0.80
TestIPv4ValidationFunction · 0.80
TestCIDRValidationFunction · 0.80
TestCIDRv6ValidationFunction · 0.80
TestCIDRv4ValidationFunction · 0.80
TestTCPAddrValidationFunction · 0.80

Calls 1

VarCtxMethod · 0.95

Tested by 15

TestNilValidatorFunction · 0.76
TestAliasTagsFunction · 0.64
TestSQLValue2ValidationFunction · 0.64
TestSQLValueValidationFunction · 0.64
TestMACValidationFunction · 0.64
TestIPValidationFunction · 0.64
TestIPv6ValidationFunction · 0.64
TestIPv4ValidationFunction · 0.64
TestCIDRValidationFunction · 0.64
TestCIDRv6ValidationFunction · 0.64
TestCIDRv4ValidationFunction · 0.64
TestTCPAddrValidationFunction · 0.64