Repository navigation
Validate exact decimal amounts and choose accepted currencies with readable fluent chains. v0.2.0 adds decimal validation, package-defined currency identifiers, and clearer examples throughout the README.
What's new
- Exact decimal bounds and equality, including values beyond floating-point precision. Accepts json.Number and defined string types without rounding or rewriting the submitted value.
- MaxScale limits written fractional digits, including trailing zeros.
- Fluent currency allowlists such as .USD().EUR().GBP(), backed by 178 package-defined ISO identifiers. Selectors form one allowlist with OR semantics.
- Focused, spaced examples and a complete currency selector list in the README.
Try it
go get github.com/goforj/validation@v0.2.0For an already decoded request:
err := validation.Validate(
validation.Decimal("amount", request.Amount).
Required().
Min("0.01").
MaxScale(2),
validation.Currency("currency", request.Currency).
Required().
USD().
EUR(),
)See the examples, complete selector list, and contracts.
Upgrading
Existing APIs and the Go 1.24 minimum are unchanged. The runtime still has no external dependencies. Currency selectors define accepted identifiers; precision policy, conversion, arithmetic, and rounding remain application-owned.
Only the root module is published. The release review records exact coverage, fuzzing, resource checks, and public-consumer verification.