Releases: heetch/walidator
Releases · heetch/walidator
new v4 API and use Go modules
This release change walidator to use Go modules, meaning that a new import path must be used:
import "github.com/heetch/walidator/v4"
The API has been substantially simplified and made more regular; most of the regular usage is compatible (most of the semantics of tags have not changed), but some little-used features have been removed and some other API features have been cleaned up.
New features
ValidationFunc
has changed to a type that allows validation functions to be more efficient in parsing arguments and checking the value type. Custom validators will need to be rewritten to use this type.- the
AddValidation
method has been added, using the newValidationFunc
type. This changes the semantics of SetValidationFunc so that it can't be used to change validator names retrospectively. min
andmax
now work work on unsigned types too.uuid
now works on named string typesrequired
now checks that maps and slices are non-nil.NewValidator
is renamed toNew
.ErrorMap
is renamed toErrors
. The new type includes information about the validator that failed as well as the message, opening the way to including more detailed failure information without compromising the ability of callers to introspect into validation error. AnErrors
will always be returned if there's an error.
Removed features
Valid
andValidator.Valid
have been removed.. For a static validation string, it's always possible to use a struct value, and for a dynamic validation string, we suggest that the logic would be better written as Go code.- the
SetValidationFunc
method has been removed. Use the new AddValidation method instead. - make len validation fail on scalar types. Using
validate:"len"
on an integer or floating point value seems like it's wrong - the "length" of an integer is not its value. - the global
Validator
instance may no longer be changed (viaSetTag
andSetValidationFunc
). This capability could easily lead to unexpected behavior when unrelated packages try to do the same thing. You can always create your ownValidator
instance. - remove
ErrorArray
andTextErr
(seeErrorMap
changes above)
v3.2.0
This release implements substantial performance increases by refactoring the code internally.
There should be no externally visible changes, but we're tagging a new minor version anyway because of the extent of the internal changes.
Some sample speed improvement benchmarks:
name old time/op new time/op delta
Latitude-4 3.58µs ±13% 0.27µs ± 1% -92.32% (p=0.016 n=5+4)
UUID-4 23.8µs ± 5% 1.0µs ±15% -95.85% (p=0.008 n=5+5)
Validate-4 13.3µs ±10% 0.6µs ± 4% -95.27% (p=0.008 n=5+5)
v3.1.0
- Add
latitude
andlongitude
tags to validate Longitude and Latitude
v3.0.0
Improvements over https://github.com/go-validator/validator v2
branch: