github.com/cohesivestack/valgo
v0.9.1
#3562 most downloaded on Go modules
cohesivestack/valgo
What this package is like to depend on
Last release 5 days ago
18 Aug 2026
Ships unpredictably
gaps range from 1 weeks to 1.2 years
Some releases are documented
notes for 10 of 18 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
39 releases · first in 2019
10 releases in the last 12 months
see the full history below
Release timeline
39 releases · May 2019 to Aug 2026Releases
latest 39-
v0.9.118 Aug 2026Release notes
Open source →Added
ValidatorString.EqualFoldandValidatorStringP.EqualFoldfor case-insensitive string validation.is.StringEqualFoldandis.StringPEqualFoldfor the equivalent stateless predicates.
Notes
EqualFolduses Go'sstrings.EqualFoldUnicode simple case folding. It does not normalize text or apply full case folding. Pointer comparisons return false for nil values. -
v0.9.015 Aug 2026Release notes
Open source →Valgo v0.9.0
Valgo v0.9.0 modernizes the numeric constructor API around Go generics and introduces reusable stateless validation predicates.
Generalized numeric constructors
The primary numeric constructors now accept every type in their respective families:
Int()andIntP()support all signed integer widths.Uint()andUintP()support all unsigned integer widths.Float()andFloatP()supportfloat32andfloat64.- User-defined numeric types remain fully type-safe.
type Attempts int8 attempts := Attempts(3) limit := uint32(100) ratio := float32(0.75) v.Int(attempts).Between(0, 5) v.Uint(limit).GreaterThan(0) v.Float(ratio).Between(0, 1)
The specialized constructors originated before Go supported generics. With Valgo now targeting modern Go versions, separate constructors for every numeric width no longer provide additional behavior or type safety.
The following constructors are now deprecated compatibility aliases:
Int8,Int16,Int32,Int64, and their pointer variantsUint8,Uint16,Uint32,Uint64, and their pointer variantsFloat32,Float64, and their pointer variants
Existing code continues to work. New code should use
Int,Uint,Float, and their pointer forms.Rune/RunePandByte/BytePremain supported because they communicate semantic meaning rather than only storage width.Stateless validation predicates
The new
github.com/cohesivestack/valgo/ispackage exposes Valgo’s built-in validation rules as type-safe boolean functions:import "github.com/cohesivestack/valgo/is" valid := !is.StringBlank(name) && is.StringLengthBetween(name, 2, 80) && is.IntGreaterOrEqualTo(stock, int16(0))
These predicates can be used in ordinary Go control flow, application-specific validation helpers, and third-party validators that want to share Valgo’s rule semantics while providing their own contexts, errors, chaining, or localization.
Valgo’s built-in validators now use the same predicates internally, keeping their behavior aligned.
Migrating
Migration only requires changing constructor names:
v.Int16(value) // Deprecated v.Int(value) // Preferred v.Float64P(&rate) // Deprecated v.FloatP(&rate) // Preferred
The inferred value type and available validation rules remain unchanged.
Documentation
- Added a complete guide to stateless predicates.
- Expanded numeric constructor and migration documentation.
- Updated reusable-validation examples and the rule index.
- Archived the v0.8.1 documentation under its own versioned route.
- Updated the bundled Valgo Agent Skill for v0.9.0.
-
v0.8.2-0.20260727014106-4b462feeb57b27 Jul 2026 pre-releaseNothing published for this version
-
v0.8.119 Jul 2026Release notes
Open source →Valgo v0.8.1 Release Notes
Valgo v0.8.1 is a backward-compatible release with shorter string length
validator names, clearer deprecation guidance, and refreshed docs.What's New
- Added shorter string length validators for
StringandStringP:
ByteLength,ByteLengthBetween,Length, andLengthBetween.
val := v.Is( v.String("Bob", "full_name").Not().Blank().LengthBetween(4, 20), )
Deprecations
The older
Of*string length methods remain available as deprecated aliases in
v0.8.1 and are planned for removal in v1.0:OfByteLength->ByteLengthOfByteLengthBetween->ByteLengthBetweenOfLength->LengthOfLengthBetween->LengthBetween
Deprecation notes were also clarified for
Validation.Error,
Validation.IsValid, andValidation.MergeErrorInRow. PreferToError,
PathValid, andMergeErrorInIndex.Docs and Maintenance
- Updated v0.8.1 examples and migration docs.
- Added the v0.8 docs archive and corrected v0.7 OR operator docs.
- Improved docs SEO metadata, sitemap handling, robots.txt, and social image.
- Updated GitHub Actions dependencies for checkout and setup-go.
Compatibility
No breaking changes are intended in this release. Existing v0.8.0 code should
continue to compile. - Added shorter string length validators for
-
v0.8.1-0.20260716024519-59c845f0409816 Jul 2026 pre-releaseNothing published for this version
-
v0.8.016 Jul 2026Release notes
Open source →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()operatorOrElse()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()andEqualTo()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 ofPathValid().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 valgo
Go 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/[email protected]
Full changelog:
v0.7.1...v0.8.0 -
v0.7.2-0.20260102095438-04628402c14402 Jan 2026 pre-releaseNothing published for this version
-
v0.7.127 Nov 2025Release notes
Open source →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
- Bump actions/checkout from 5 to 6 by @dependabot[bot] in #54
-
v0.7.021 Sep 2025Release notes
Open source →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,DoInCell(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
iftrees 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 andNaN(),Infinite(),Finite()for floats. Constructors likev.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.005 Sep 2025Release notes
Open source →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.027 Jun 2025Release notes
Open source →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.0
After:
val.ToError() // For standard error handling val.ToValgoError() // For detailed error information
Full Changelog: v0.4.2...v0.5.0
- Returns validation errors as a standard Go
-
v0.4.3-0.20250627103101-f74e7fea74d327 Jun 2025 pre-releaseNothing published for this version
-
v0.4.224 Jun 2025Release notes
Open source →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.108 Apr 2024Release notes
Open source →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.1-0.20240408035208-e90fa82dacd208 Apr 2024 pre-releaseNothing published for this version
-
v0.4.029 Mar 2024Nothing published for this version
-
v0.3.017 Mar 2024Nothing published for this version
-
v0.2.5-0.20240317062306-44b9a8b9ef1717 Mar 2024 pre-releaseNothing published for this version
-
v0.2.5-0.20230905161715-d1107e61a61205 Sep 2023 pre-releaseNothing published for this version
-
v0.2.5-0.20230905161023-84b423463b9605 Sep 2023 pre-releaseNothing published for this version
-
v0.2.5-0.20230905121157-85fa2953c25c05 Sep 2023 pre-releaseNothing published for this version
-
v0.2.5-0.20230410153805-9c8781df70d710 Apr 2023 pre-releaseNothing published for this version
-
v0.2.409 Apr 2023Nothing published for this version
-
v0.2.317 Mar 2023Nothing published for this version
-
v0.2.214 Mar 2023Nothing published for this version
-
v0.2.2-0.20230314113128-3a6cba55a8aa14 Mar 2023 pre-releaseNothing published for this version
-
v0.2.107 Mar 2023Nothing published for this version
-
v0.2.1-0.20230219162514-b944469f9f6419 Feb 2023 pre-releaseNothing published for this version
-
v0.2.019 Feb 2023Nothing published for this version
-
v0.1.004 Dec 2022Nothing published for this version
-
v0.0.0-20221108170755-41af02d64db508 Nov 2022 pre-releaseNothing published for this version
-
v0.0.0-20221031191228-0db1cbe7ac7c31 Oct 2022 pre-releaseNothing published for this version
-
v0.0.0-20210914230158-9b1df993339614 Sep 2021 pre-releaseNothing published for this version
-
v0.0.0-20210914221833-687739b9f1ec14 Sep 2021 pre-releaseNothing published for this version
-
v0.0.0-20210521201014-f55b61fbaeb021 May 2021 pre-releaseNothing published for this version
-
v0.0.0-20200514001853-00298a7a0fd214 May 2020 pre-releaseNothing published for this version
-
v0.0.0-20200512003659-8ca362a7c70312 May 2020 pre-releaseNothing published for this version
-
v0.0.0-20191230152757-2680ecd6606f30 Dec 2019 pre-releaseNothing published for this version
-
v0.0.0-20190513035213-4a72685acfca13 May 2019 pre-releaseNothing published for this version