Write any validations declaratively.
go get go-simpler.org/check
Use That
/Thatf
to write conditions to check, multiple calls can be chained.
The last call in the chain must be FirstError
, AllErrors
, or JoinErrors
.
err := check.
That(user.Name != "", errEmptyName).
Thatf(user.Age >= 18, "%d y.o. is too young", user.Age).
Thatf(isEmail(user.Email), "%s is invalid email", user.Email).
JoinErrors() // or FirstError() / AllErrors().