Skip to content

Releases: hymns/go-validator

v1.1.0

17 May 07:38

Choose a tag to compare

What's new

Rule caching

Rule strings are now parsed once and cached via sync.Map. User-supplied regex/not_regex patterns are also compiled and cached — no redundant work on repeated validation calls.

Typed rule builder

Compile-safe, IDE-friendly alternative to pipe strings:

validator.Rules{
    "email": validator.R().Required().Email().Max(100).Build(),
    "age":   validator.R().Required().Integer().Min(18).Build(),
    "role":  validator.R().Required().In("admin", "user").Build(),
}

Bail — fixed & extended

  • Per-field: "bail|required|email" now correctly stops checking remaining rules on first failure (was a no-op before)
  • Global: .Bail() on the validator stops after the first field with an error
v := validator.Make(input, rules).Bail()

Nested validation

Dot-notation support for nested maps:

validator.Rules{
    "user.name":             "required|min:3",
    "user.address.postcode": "required|digits:5",
}

Array wildcard

Validate every element of an array with field.*. Errors are keyed as field.0, field.1, etc.

validator.Rules{
    "tags":   "required|array",
    "tags.*": "required|string|min:2",
}

Initial Release

16 May 19:38

Choose a tag to compare