Skip to content

Commit d423756

Browse files
Dean KarnDean Karn
authored andcommitted
Merge pull request #161 from joeybloggs/v7-development
Changes for v7
2 parents 305c50f + ce06c47 commit d423756

File tree

9 files changed

+2173
-437
lines changed

9 files changed

+2173
-437
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ _testmain.go
2424
*.prof
2525
*.test
2626
*.out
27+
*.txt
2728
cover.html
2829
README.html

README.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Package validator
33

44
[![Join the chat at https://gitter.im/bluesuncorp/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bluesuncorp/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
55
[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/487374/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
6-
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v6)](https://coveralls.io/r/bluesuncorp/validator?branch=v6)
7-
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v6?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v6)
6+
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v7)](https://coveralls.io/r/bluesuncorp/validator?branch=v7)
7+
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v7?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v7)
88

99
Package validator implements value validations for structs and individual fields based on tags.
1010

1111
It has the following **unique** features:
1212

13-
- Cross Field and Cross Struct validations.
13+
- Cross Field and Cross Struct validations by using validation tags or custom validators.
1414
- Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated.
1515
- Handles type interface by determining it's underlying type prior to validation.
1616
- Handles custom field types such as sql driver Valuer see [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29)
@@ -20,20 +20,20 @@ Installation
2020

2121
Use go get.
2222

23-
go get gopkg.in/bluesuncorp/validator.v6
23+
go get gopkg.in/bluesuncorp/validator.v7
2424

2525
or to update
2626

27-
go get -u gopkg.in/bluesuncorp/validator.v6
27+
go get -u gopkg.in/bluesuncorp/validator.v7
2828

2929
Then import the validator package into your own code.
3030

31-
import "gopkg.in/bluesuncorp/validator.v6"
31+
import "gopkg.in/bluesuncorp/validator.v7"
3232

3333
Usage and documentation
3434
------
3535

36-
Please see http://godoc.org/gopkg.in/bluesuncorp/validator.v6 for detailed usage docs.
36+
Please see http://godoc.org/gopkg.in/bluesuncorp/validator.v7 for detailed usage docs.
3737

3838
##### Examples:
3939

@@ -143,7 +143,7 @@ import (
143143
"fmt"
144144
"reflect"
145145

146-
"gopkg.in/bluesuncorp/validator.v6"
146+
"gopkg.in/bluesuncorp/validator.v7"
147147
)
148148

149149
// DbBackedUser User struct
@@ -187,29 +187,35 @@ func ValidateValuer(field reflect.Value) interface{} {
187187

188188
Benchmarks
189189
------
190-
###### Run on MacBook Pro (Retina, 15-inch, Late 2013) 2.6 GHz Intel Core i7 16 GB 1600 MHz DDR3
191-
NOTE: allocations for structs are up from v5, however ns/op for parallel operations are way down.
192-
It was a decicion not to cache struct info because although it reduced allocation to v5 levels, it
193-
hurt parallel performance too much.
190+
###### Run on MacBook Pro (Retina, 15-inch, Late 2013) 2.6 GHz Intel Core i7 16 GB 1600 MHz DDR3 using Go 1.5
194191
```go
195-
$ go test -cpu=4 -bench=. -benchmem=true
196192
PASS
197-
BenchmarkFieldSuccess-4 5000000 318 ns/op 16 B/op 1 allocs/op
198-
BenchmarkFieldFailure-4 5000000 316 ns/op 16 B/op 1 allocs/op
199-
BenchmarkFieldCustomTypeSuccess-4 3000000 492 ns/op 32 B/op 2 allocs/op
200-
BenchmarkFieldCustomTypeFailure-4 2000000 843 ns/op 416 B/op 6 allocs/op
201-
BenchmarkFieldOrTagSuccess-4 500000 2384 ns/op 20 B/op 2 allocs/op
202-
BenchmarkFieldOrTagFailure-4 1000000 1295 ns/op 384 B/op 6 allocs/op
203-
BenchmarkStructSimpleSuccess-4 1000000 1175 ns/op 24 B/op 3 allocs/op
204-
BenchmarkStructSimpleFailure-4 1000000 1822 ns/op 529 B/op 11 allocs/op
205-
BenchmarkStructSimpleCustomTypeSuccess-4 1000000 1302 ns/op 56 B/op 5 allocs/op
206-
BenchmarkStructSimpleCustomTypeFailure-4 1000000 1847 ns/op 577 B/op 13 allocs/op
207-
BenchmarkStructSimpleSuccessParallel-4 5000000 339 ns/op 24 B/op 3 allocs/op
208-
BenchmarkStructSimpleFailureParallel-4 2000000 733 ns/op 529 B/op 11 allocs/op
209-
BenchmarkStructComplexSuccess-4 200000 7104 ns/op 368 B/op 30 allocs/op
210-
BenchmarkStructComplexFailure-4 100000 11996 ns/op 2861 B/op 72 allocs/op
211-
BenchmarkStructComplexSuccessParallel-4 1000000 2252 ns/op 368 B/op 30 allocs/op
212-
BenchmarkStructComplexFailureParallel-4 300000 4691 ns/op 2862 B/op 72 allocs/op
193+
BenchmarkFieldSuccess-4 5000000 290 ns/op 16 B/op 1 allocs/op
194+
BenchmarkFieldFailure-4 5000000 286 ns/op 16 B/op 1 allocs/op
195+
BenchmarkFieldDiveSuccess-4 500000 2497 ns/op 384 B/op 19 allocs/op
196+
BenchmarkFieldDiveFailure-4 500000 3022 ns/op 752 B/op 23 allocs/op
197+
BenchmarkFieldCustomTypeSuccess-4 3000000 446 ns/op 32 B/op 2 allocs/op
198+
BenchmarkFieldCustomTypeFailure-4 2000000 778 ns/op 416 B/op 6 allocs/op
199+
BenchmarkFieldOrTagSuccess-4 1000000 1287 ns/op 32 B/op 2 allocs/op
200+
BenchmarkFieldOrTagFailure-4 1000000 1125 ns/op 400 B/op 6 allocs/op
201+
BenchmarkStructSimpleCustomTypeSuccess-4 1000000 1225 ns/op 80 B/op 5 allocs/op
202+
BenchmarkStructSimpleCustomTypeFailure-4 1000000 1742 ns/op 608 B/op 13 allocs/op
203+
BenchmarkStructPartialSuccess-4 1000000 1304 ns/op 400 B/op 11 allocs/op
204+
BenchmarkStructPartialFailure-4 1000000 1818 ns/op 784 B/op 16 allocs/op
205+
BenchmarkStructExceptSuccess-4 2000000 869 ns/op 368 B/op 9 allocs/op
206+
BenchmarkStructExceptFailure-4 1000000 1308 ns/op 400 B/op 11 allocs/op
207+
BenchmarkStructSimpleCrossFieldSuccess-4 2000000 973 ns/op 128 B/op 6 allocs/op
208+
BenchmarkStructSimpleCrossFieldFailure-4 1000000 1519 ns/op 528 B/op 11 allocs/op
209+
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4 1000000 1382 ns/op 160 B/op 8 allocs/op
210+
BenchmarkStructSimpleCrossStructCrossFieldFailure-4 1000000 1931 ns/op 560 B/op 13 allocs/op
211+
BenchmarkStructSimpleSuccess-4 1000000 1132 ns/op 48 B/op 3 allocs/op
212+
BenchmarkStructSimpleFailure-4 1000000 1735 ns/op 560 B/op 11 allocs/op
213+
BenchmarkStructSimpleSuccessParallel-4 3000000 363 ns/op 48 B/op 3 allocs/op
214+
BenchmarkStructSimpleFailureParallel-4 2000000 705 ns/op 560 B/op 11 allocs/op
215+
BenchmarkStructComplexSuccess-4 200000 6935 ns/op 432 B/op 27 allocs/op
216+
BenchmarkStructComplexFailure-4 200000 11059 ns/op 2920 B/op 69 allocs/op
217+
BenchmarkStructComplexSuccessParallel-4 1000000 2220 ns/op 432 B/op 27 allocs/op
218+
BenchmarkStructComplexFailureParallel-4 300000 4739 ns/op 2920 B/op 69 allocs/op
213219
```
214220

215221
How to Contribute

0 commit comments

Comments
 (0)