Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3ab458c
Updates
Aug 14, 2015
2ea9043
update to handle nested map + Array + Slice structs
Aug 14, 2015
81e29d3
Complete Test Cases for getStructFieldOK
Aug 14, 2015
d19088f
Code Cleanup + some renaming
Aug 14, 2015
2fe52ca
finish eqcsfield + test coverage
Aug 15, 2015
8aea478
Update isGtField to user new functions
Aug 15, 2015
5989727
complete test coverage for IsGteField after conversion
Aug 15, 2015
4cbf065
convert isLtField & isLteField to use new functions + test coverage
Aug 15, 2015
3a07915
Add cross struct map support for all types not just string
Aug 16, 2015
cd50c5e
Added necsfield method + tests
Aug 16, 2015
327aa2e
Add gtcsfield, gtecsfield, ltcsfield and ltecsfield
Aug 16, 2015
1fbc384
Complete test coverage for gecsfield, gtecsfield, ltcsfield and ltecs…
Aug 17, 2015
8ff687a
code cleanup
Aug 17, 2015
3697be9
update benchmarks, pretty much the same
Aug 17, 2015
8ae139a
Partially Merged in Partial struct methods + Tests
Aug 17, 2015
4a8a489
Merge remote-tracking branch 'upstream/v7-development' into merge
Aug 17, 2015
656ae32
Updated PanicMatches after assertion library updates
Aug 17, 2015
387cfe5
Complete adding StructPartial and StructExcept
Aug 17, 2015
4f46e02
Add documentation for cross struct validation tags + Struct Partials
Aug 19, 2015
883731a
Updates + Benchmarks
Aug 19, 2015
7757a22
Add benchmark for StructExcept
Aug 19, 2015
b5317c5
Update examples_test.go
Aug 19, 2015
d7b348e
Merge branch 'v6-development' into v7-development
Aug 19, 2015
14b9094
Backport v7 updates
Aug 19, 2015
19d8904
Merge pull request #157 from joeybloggs/v6-development
Aug 19, 2015
3f4f84c
Merge branch 'v6-development' into merge
Aug 19, 2015
15fdf82
Update verbiage for unique features for v7 cross struct cross field v…
Aug 19, 2015
55f9e44
Update benchmarks for new go 1.5!
Aug 19, 2015
43d7f25
update nefield and necsfield to hav own logic instead of calling !eqf…
Aug 20, 2015
ce06c47
rename some variable for clarity
Aug 20, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ _testmain.go
*.prof
*.test
*.out
*.txt
cover.html
README.html
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Package validator

[![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)
[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/487374/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v6)](https://coveralls.io/r/bluesuncorp/validator?branch=v6)
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v6?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v6)
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v7)](https://coveralls.io/r/bluesuncorp/validator?branch=v7)
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v7?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v7)

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

It has the following **unique** features:

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

Use go get.

go get gopkg.in/bluesuncorp/validator.v6
go get gopkg.in/bluesuncorp/validator.v7

or to update

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

Then import the validator package into your own code.

import "gopkg.in/bluesuncorp/validator.v6"
import "gopkg.in/bluesuncorp/validator.v7"

Usage and documentation
------

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

##### Examples:

Expand Down Expand Up @@ -143,7 +143,7 @@ import (
"fmt"
"reflect"

"gopkg.in/bluesuncorp/validator.v6"
"gopkg.in/bluesuncorp/validator.v7"
)

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

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

How to Contribute
Expand Down
Loading