API Reference
A compact reference for the public surface. For prose-style docs see the Guide.
For the full Go API including private helpers, head to pkg.go.dev/github.com/wuhan005/govalid.
Top-level
go
// Validate v and return the list of failures plus an overall ok flag.
func Check(v interface{}, lang ...language.Tag) (errs []*ErrContext, ok bool)
// Merge templates into the given locale (default when omitted).
func SetMessageTemplates(templates map[string]string, lang ...language.Tag)Variables
go
// Tag names — change at startup if you need a different namespace.
var RulesField = "valid"
var LabelField = "label"
var MessageField = "msg"
// Placeholders used in templates that contain {field} / {limit}.
var FieldNamePlaceholder = "{field}"
var FieldLimitPlaceholder = "{limit}"
// Registered checkers. Mutate at startup.
var Checkers map[string]CheckFunc
// MobilePattern is exposed for swap-in custom mobile rules.
var MobilePattern *regexp.RegexpTypes
CheckFunc— checker function signature.CheckerContext— what every checker receives.ErrContext— what every failure returns.
Helpers
go
func NewErrorContext(c CheckerContext) *ErrContext
func MakeUserDefinedError(msg string) *ErrContext
func MakeValueTypeError(c CheckerContext) *ErrContext
func MakeCheckerParamError(c CheckerContext) *ErrContext
func MakeCheckerNotFoundError(c CheckerContext) *ErrContext
func MakeFieldNotFoundError(c CheckerContext) *ErrContext