Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.01 KB

README.md

File metadata and controls

27 lines (20 loc) · 1.01 KB

check

checks pkg.go.dev goreportcard codecov

Write any validations declaratively.

📦 Install

go get go-simpler.org/check

📋 Usage

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().