Releases: cohesivestack/valgo
v0.7.1
What's Changed
- Bump actions/checkout from 5 to 6 by @dependabot[bot] in #54
Full Changelog: v0.7.0...v0.7.1
Parent namespace invalidation support for IsValid()
IsValid() now supports parent namespaces in nested validation structures. When a nested field is invalid, all parent namespaces are automatically marked as invalid, enabling conditional checks at any level of the object graph.
What's new
- Parent namespace tracking: When a field like
"person.addresses[0].line1"is invalid, parent namespaces ("person","person.addresses","person.addresses[0]") are also marked as invalid - Improved
IsValid()behavior:IsValid()is now parent-namespace awareness - Works with all namespace types: Supports dot-separated namespaces (
In()) and indexed namespaces (InRow(),InCell())
Example
val := v.In("person",
v.InRow("addresses", 0,
v.Is(v.String("", "line1").Not().Blank()),
),
)
// Check validity at any namespace level
if !val.IsValid("person.addresses") {
// Handle address validation errors
}Benefits
- Write conditional logic at any namespace level without checking individual leaf fields
- More intuitive API for nested validation structures
v0.7.0
Valgo v0.7.0 — Ergonomics + Type-safety
This release focuses on two things: (1) fluent control over validation flow and (2) type-safe validators that remove codegen and width-specific types. PR: #50
New validation helpers (sessions): InCell, If, When, Do
InCell(name, index, v)— Run validators in an indexed namespace (great for slices of primitives or flat tables). Errors are grouped likephones[2].number, keeping messages precise without manual prefixing.If(condition, validation)— Conditionally merge another validation session. Perfect for optional blocks.When(condition, func(val *Validation))— LikeIf, but runs a function to build rules. Keeps linear, readable control-flow.Do(func(val *Validation))— Execute custom logic with access to the session (e.g., compute, branch, or attach custom errors).
Why this matters: these helpers eliminate boilerplate if trees around validation, preserve explicit intent, and keep error paths tied to the exact field/cell that failed.
Numeric validators — now generic, faster to use, easier to maintain
We replaced generated, width-specific validators with single generic types per family:
ValidatorInt[T ~int|~int8|~int16|~int32|~int64]ValidatorUint[T ~uint|~uint8|~uint16|~uint32|~uint64]ValidatorFloat[T ~float32|~float64]
New rules include Positive()/Negative() for integers and NaN(), Infinite(), Finite() for floats. Constructors like v.Int16(...), v.Uint64(...), v.Float32(...) still work and now return the generic types. You keep your call sites; declared types may need a tweak (see “Breaking changes”).
Why this matters: less API surface, clearer autocompletion, fewer mistakes during refactors, and no codegen to maintain.
Comparable & Typed validators
ValidatorComparable[T comparable]— Type-safe equality and membership:EqualTo,InSlice, plusPassing.ValidatorTyped[T]— A type-safe alternative toAnywhen you want custom rules on your own domain types without losing compile-time checks; includesPassing(func(T) bool)andNil()for pointer forms.
Why this matters: you keep Go’s type guarantees (no accidental cross-type comparisons) and still write concise, expressive rules.
Migration & breaking changes
-
Numeric validators: width-specific types (e.g.,
ValidatorInt16) are replaced by generics.- Before:
var a ValidatorInt16 - After:
var a *ValidatorInt[int16]
Constructors (v.Int16(...), etc.) are unchanged.
- Before:
-
Any.EqualTo()is deprecated; useComparable.EqualTo()to keep type-safety.
Quick examples
Validate items in a slice with stable error paths:
for i, phone := range phones {
val = val.InCell("phones", i, v.Is(
v.String(phone, "number").Not().Blank().OfLengthBetween(7, 15),
))
}Conditionally attach rules with If / When:
val.
If(hasMiddle, v.Is(v.String(m, "middle").OfLengthBetween(2, 50))).
When(isTrial, func(vv *v.Validation) {
vv.Is(v.Int(daysLeft, "days_left").GreaterThan(0))
})Comparable & Typed:
// Comparable
v.Is(v.Comparable(status, "status").InSlice([]Status{"active","paused"}))
// Typed custom rule
type Plan string
v.Is(v.Typed(plan, "plan").Passing(func(p Plan) bool { return p == "pro" || p == "team" }))Bottom line: v0.7.0 gives you cleaner control-flow (InCell/If/When/Do), safer equality and domain rules (Comparable, Typed), and a smaller, more coherent numeric API with new positivity/NaN/∞ checks—without disrupting most call sites.
v0.6.0
What's Changed
- Add rune length validators to support non-Latin alphabet languages by @mintc2 in #46
- Feature/expand rune tests by @carlosforero in #48
New Contributors
Full Changelog: v0.5.0...v0.6.0
v0.5.0
What's Changed
✨ New Error Handling Functions
This release introduces two new error handling functions for better Go integration:
ToError() Function
- Returns validation errors as a standard Go
errorinterface - Perfect for idiomatic error handling and integration with Go's native error system
ToValgoError() Function
- Returns validation errors as a concrete
*valgo.Errortype - Provides access to rich, structured error details including per-field messages
Deprecated Error() Function
- The existing
Error()function is now deprecated and will be removed in v1.0 - This resolves naming conflicts with Go's error interface implementation convention
🔧 Other Changes
- Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 by @dependabot[bot] in #37
- Fix minor typo in README by @carlosforero in #39
📚 Quick Migration
Before (deprecated):
val.Error() // Will be removed in v1.0After:
val.ToError() // For standard error handling
val.ToValgoError() // For detailed error informationFull Changelog: v0.4.2...v0.5.0
v0.4.2
What's Changed
- Add support for Hungarian by @voroskoi in #31
- fix: translate ErrorKeyPassing and ErrorKeyNotPassing to Hungarian by @carlosforero in #35
- Bump golang.org/x/text from 0.14.0 to 0.16.0 by @dependabot in #30
New Contributors
- @voroskoi made their first contribution in #31
- @dependabot made their first contribution in #30
Full Changelog: v0.4.1...v0.4.2
v0.4.1
What's Changed
- Add CI Workflow using GitHub Actions by @gaby in #20
- Feature/ensure consistency in docs examples by @carlosforero in #24
- Simplify CI to Ubuntu-only testing. by @carlosforero in #25
- Feature/upgrade packages by @carlosforero in #26
New Contributors
Full Changelog: v0.4.0...v0.4.1
v0.4.0
What's Changed
- Variadic Parameters for
IsandCheck: TheIsandCheckfunctions now accept variadic parameters, streamlining validation by enabling multiple validators in a single call. This enhancement simplifies the validation process, reduces code verbosity, and promotes the reuse of validation logic across projects. For more details, see PR #19.
Full Changelog: v0.3.0...v0.4.0
v0.3.0
What's Changed
- Add functions to merge Valgo errors from validated sessions by @carlosforero in #12
- Add Time Validator by @carlosforero in #16
- Add new
Oroperator function to Validators. by @carlosforero in #17 - fix: custom validation title by @amsal in #15
New Contributors
Full Changelog: v0.2.4...v0.3.0
v0.2.4
What's Changed
- Make
validationFactorytype public by @carlosforero in #11
This Release makes validationFactory type public: The validationFactory type has been made public and renamed to ValidationFactory, enhancing flexibility and enabling developers to reuse the factory more effectively in various scenarios.
Full Changelog: v0.2.3...v0.2.4
v0.2.3
What's Changed
- Fix generator to use filepath instead of path by @carlosforero in #10
Full Changelog: v0.2.2...v0.2.3