v0.9.0
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/RuneP and Byte/ByteP remain supported because they communicate semantic meaning rather than only storage width.
Stateless validation predicates
The new github.com/cohesivestack/valgo/is package 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) // PreferredThe 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.