An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
When
and Each
rulesThanks to @NathanBaulch for the great contribution!
Skip.When()
to support conditional skipping validation rules (thanks to @maratori!)EmailFormat
validation rule to validate an email address without checking the existence of MX recordis.Domain
rule. (thanks to @TheSecEng)Nil
and Empty
rules (thanks to @samber)Else
clause to the When
conditional validation construct (thanks to @samber)Length
rule when requiring zero length (thanks to @0perl)RequiredRule
struct is made public (thanks to @erdaltsksn)validation.When()
and validation.Required.When()
to support conditional validation. Thanks to @mehran-prs for the great contribution to this new feature!validation.Error
as the validation error type. It supports error code and parameter placeholders in error messages, which allows checking validation errors programmatically and translating error messages based on error codes. Thanks to @mehran-prs for the great contribution to this new feature!Errors.Error()
. Thanks to @geekflyer for the profiling work and code contribution!validation.In
rule now supports less restrictive equality comparison by using reflect.DeepEqual()
Added support for context-aware validation.
Added support for go mod
MultipleOf
rule (see #49)Length
rule when Min and Max are the same