Releases: go-playground/validator
Release 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/op
Release 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.
Release v5.9
At long last support for traversing through slice, array and maps and validating at any or all levels!
see documentation for the new "dive" tag
benchmarks have slightly increased ns/op and B/ops for this functionality and an additional allocation for single field validation.
$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkValidateField-4 3000000 439 ns/op 192 B/op 2 allocs/op
BenchmarkValidateStructSimple-4 1000000 2382 ns/op 656 B/op 10 allocs/op
BenchmarkTemplateParallelSimple-4 2000000 910 ns/op 656 B/op 10 allocs/op
BenchmarkValidateStructLarge-4 100000 13201 ns/op 4309 B/op 60 allocs/op
BenchmarkTemplateParallelLarge-4 300000 5240 ns/op 4311 B/op 60 allocs/op
for #78
Release 5.8.1
Fix Issue with nested struct as pointer being nil causing validation to fail
Release 5.8
RGB and RGBA regexes
updated to properly validate rgb 255 or rgb percentabe, it no longer allows mixing and matching; either all percentages or all numbers from 0-155
GODOC
Added some godoc examples to better illustrate functions usages
Validators
A huge shout out to @asaskevich for having allot of these validations that I ported from his govalidator, I would not have been able to add them so quickly without his groundwork, Thanks!
ADDED:
isbn10
isbn13
uuid
uuid3
uuid4
uuid5
ascii
printascii
multibyte
datauri
latitude
longitude
ssn