v0.8.0
Valgo v0.8.0
Valgo v0.8.0 introduces OrElse() short-circuiting, improved localized error messages for OR groups, validation-aware conditional flows, locale fallbacks for custom validators, and a new documentation website.
Improved OR error messages
Or() continues to combine adjacent rules as alternatives within the same validator chain:
val := v.Is(
v.Int(status, "status").
EqualTo(1).
Or().EqualTo(2).
Or().EqualTo(3),
)When every alternative fails, Valgo now returns one localized message containing all failures:
Status must be equal to "1"; Status must be equal to "2"; or Status must be equal to "3"
OR grouping and precedence remain consistent with v0.7:
A.Or().B.C == (A OR B) AND C
A.B.Or().C == A AND (B OR C)
Localized OR formatting is available in English, Spanish, German, and Hungarian.
New OrElse() operator
OrElse() introduces an OR boundary with short-circuiting. If the rule or OR group on its left succeeds, the remainder of the validator chain is skipped.
This is useful for accepting an optional value immediately and applying additional rules only when it is present:
val := v.Is(
v.String(value, "value").
Empty().
OrElse().
MinLength(5).
EqualTo("test"),
)This behaves as:
Empty() OR (MinLength(5) AND EqualTo("test"))
If Empty() succeeds, MinLength() and EqualTo() are not evaluated. Otherwise, validation continues through the rules on the right.
Like Or(), OrElse() takes no arguments and uses localized, joined error messages when all alternatives fail.
Validation-result queries
New methods make it easier to inspect results recorded in a validation session:
PathValid(path)checks a field or namespace.AllValid(paths...)returns whether every supplied path is valid.AnyValid(paths...)returns whether at least one supplied path is valid.
IsValid() remains available but is deprecated in favor of PathValid().
Validation-aware conditional flows
New fluent methods can merge validations or execute callbacks based on the current validation results:
IfValid()IfPathValid()IfAllValid()IfAnyValid()WhenValid()WhenPathValid()WhenAllValid()WhenAnyValid()
These methods help express dependent validation steps directly within a validation chain.
Locale fallbacks for custom validators
Custom validators can now provide default messages for their own error keys:
context.WithLocaleFallback(locale)Fallback entries are used only when the active locale does not already define the key. Built-in messages and consumer overrides continue to take precedence.
New documentation website
This release introduces comprehensive documentation powered by Astro and Starlight, including:
- Getting-started and migration guides
- Validator and rule references
- Conditional-flow and error-handling guides
- Custom-validator documentation
- Practical cookbook examples
- Versioned v0.7 documentation
Explore the documentation at [valgo.build](https://valgo.build).
The generated Go API reference remains available at [pkg.go.dev/github.com/cohesivestack/valgo](https://pkg.go.dev/github.com/cohesivestack/valgo).
Valgo Agent Skill
The repository now includes a Valgo Agent Skill for supported AI coding assistants:
npx skills add cohesivestack/valgo --skill valgoGo versions
Valgo v0.8 is tested with Go 1.23 and later. Using one of these versions is recommended.
Installation
go get github.com/cohesivestack/valgo@v0.8.0Full changelog: v0.7.1...v0.8.0