Releases: go-playground/validator
Release 6.1
Updated "required" validation logic & updated invalid field type handling
updated required validator to check for a nil value for types:
slice, map, pointer, interface, channel and function.
updated traverseField to handle invalid field type.
Release 6.0.2
split our assertion functions like IsEqual, Equal, NotEqual, PanicMatches etc...
into another library https://github.com/bluesuncorp/assert so that I can use them
in other projects.
Add single Field validation example
Release 6.0.1
Updating Docs. & Benchmarks
- update doc.go, some v5 specific notes were left.
- Split out benchmarks into Success and Failure for more realistic numbers.
I was validating 2 structs within the benchmarks, both a Successful and
Failing struct which was artificially inflating the numbers.
$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkFieldSuccess-4 5000000 326 ns/op 16 B/op 1 allocs/op
BenchmarkFieldFailure-4 5000000 327 ns/op 16 B/op 1 allocs/op
BenchmarkFieldOrTagSuccess-4 500000 2738 ns/op 20 B/op 2 allocs/op
BenchmarkFieldOrTagFailure-4 1000000 1341 ns/op 384 B/op 6 allocs/op
BenchmarkStructSimpleSuccess-4 1000000 1282 ns/op 24 B/op 3 allocs/op
BenchmarkStructSimpleFailure-4 1000000 1870 ns/op 529 B/op 11 allocs/op
BenchmarkStructSimpleSuccessParallel-4 5000000 348 ns/op 24 B/op 3 allocs/op
BenchmarkStructSimpleFailureParallel-4 2000000 807 ns/op 529 B/op 11 allocs/op
BenchmarkStructComplexSuccess-4 200000 8081 ns/op 368 B/op 30 allocs/op
BenchmarkStructComplexFailure-4 100000 12418 ns/op 2861 B/op 72 allocs/op
BenchmarkStructComplexSuccessParallel-4 500000 2249 ns/op 369 B/op 30 allocs/op
BenchmarkStructComplexFailureParallel-4 300000 5183 ns/op 2863 B/op 72 allocs/opRelease 6.0
And the long awaited v6 is here!
Highlights
- Code has been completely refactored for simplicity, maintenance, speed, efficiency and is DRY
- validator.New now accepts a config struct to allow for adding of new param and keep backward compatibility
- Hierarchy error structure has been removed both validate "Field" and "Struct" now returns ValidationErrors which is really a map[string]*FieldError, but had to type it so ValidationErrors can be used as a regular error type.
- Func ( validation funcs ) have been updated to the following input params (topStruct reflect.Value, currentStruct reflect.Value, field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string) was already getting the reflect Value, so why pass it around by interface just to look at the value all over again.
- When validating a struct the Struct Name is prepended to the error key i.e. Struct User and Field Name the error key will be "User.Name"
- v6 is intended to be a long term stable release and only additions to validation functions.
Benchmarks
$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkField-4 5000000 316 ns/op 16 B/op 1 allocs/op
BenchmarkFieldOrTag-4 500000 2437 ns/op 20 B/op 2 allocs/op
BenchmarkStructSimple-4 500000 3101 ns/op 553 B/op 14 allocs/op
BenchmarkStructSimpleParallel-4 1000000 1140 ns/op 553 B/op 14 allocs/op
BenchmarkStructComplex-4 100000 19519 ns/op 3230 B/op 102 allocs/op
BenchmarkStructComplexParallel-4 200000 6681 ns/op 3232 B/op 102 allocs/opRelease 5.10.3
Changed CI from travis to semaphore
Release 5.10.2
updated the following basked in functions to use utf8.RuneCountInString for string length comparisons:
hasLengthOf
isGt
isGte
isLt
isLte
thanks @zhing for the pulls request
Release v5.10.1
Fixed issue where interface was set but had no validation tag
for #106
Release 5.10
updated to use native go sync.Pool for better parallel speed
updated goveralls so that if their service, which at the time of writing is all buggered up, won't stop travis-ci success
NOTE: to support sync.Pool the library no longer supports go 1.2
Release 5.9.2
Updated Flatten Function to handle new dive logic for #88
Release 5.9.1
Correct interface panic issue #85 thanks to @manucorporat and @semihalev for finding it
Add interface type handling, not the library will determine the underlying type and validate it.