Checkers
go
type CheckFunc func(ctx CheckerContext) *ErrContext
var Checkers map[string]CheckFuncThe Checkers map is the registry of validation functions, keyed by rule name. Built-in entries:
go
var Checkers = map[string]CheckFunc{
"required": required,
"min": min,
"max": max,
"minlen": minlen,
"maxlen": maxlen,
"alpha": alpha,
"alphanumeric": alphaNumeric,
"alphadash": alphaDash,
"username": userName,
"email": email,
"ipv4": ipv4,
"mobile": mobile,
"tel": tel,
"phone": phone,
"idcard": idCard,
"equal": equal,
"list": list,
}For per-rule semantics, see Built-in Checkers.
Adding a checker
go
govalid.Checkers["myRule"] = func(c govalid.CheckerContext) *govalid.ErrContext {
// ...
return nil
}Replacing a checker
Same syntax — assigning to an existing key overrides the built-in:
go
govalid.Checkers["required"] = func(c govalid.CheckerContext) *govalid.ErrContext {
// override built-in semantics
return nil
}Removing a checker
go
delete(govalid.Checkers, "idcard")References to the deleted rule in struct tags will trigger MakeCheckerNotFoundError at runtime.
Concurrency
The map itself is not synchronized for writes. Mutate it once at program startup, then leave it alone while requests are flying. Reads from multiple goroutines are safe under the standard Go map contract (no concurrent writer).