Commit graph

161 commits

Author SHA1 Message Date
Dean Karn
c0f05c7b3d fix required_* 2019-11-17 13:02:10 -08:00
Dean Karn
cc25246f01 fix required_without_* 2019-09-29 13:39:27 -07:00
Dean Karn
54da7fa48f fix linting and spelling errors 2018-05-05 09:23:38 -07:00
Dean Karn
5e036656b8 Add hostname_rfc1123 validation 2018-02-15 08:50:04 -08:00
Dean Karn
b962f3d7d5 Correct Var tagCache locking 2018-01-14 13:58:17 -08:00
Dean Karn
b1f51f36f1
Correct consequtive or logic (#330) 2017-12-13 08:54:38 -08:00
Dean Karn
61caf9d303
add map key validation support (#324) 2017-11-12 20:58:10 -08:00
Dean Karn
0b5dc7605b Add isdefault validation 2017-08-20 09:53:47 -07:00
Dean Karn
0f6f568263 Add contextual validation support via context.Context (#296)
* Add contextual validation support via context.Context

Added:
- RegisterValidationCtx
- RegisterStructValidationCtx
- StructCtx
- StructFilteredCtx
- StructPartialCtx
- StructExceptCtx
- VarCtx
- VarWithValueCtx
2017-07-29 20:49:32 -07:00
Dean Karn
fb68f39656 Add Access to Field Name from FieldLevel (#284) 2017-06-11 22:26:53 -07:00
Dean Karn
077c3830f3 Correct Namespace when array or map of structs
namespace was incorrect when array or map of structs, see #266
2016-12-22 21:45:03 -05:00
Dean Karn
49fccadad1 correct structonly functionality
- structonly wasn’t behaving correctly when not used with an accompanying struct validation.
2016-12-06 20:51:45 -05:00
Dean Karn
4e43fa1562 change field cache to array
- errors now come out in order for unit tests
- speed improvement using array vs map

benchmark                                                       old ns/op     new ns/op     delta
BenchmarkFieldSuccess-8                                         101           100           -0.99%
BenchmarkFieldSuccessParallel-8                                 33.2          33.7          +1.51%
BenchmarkFieldFailure-8                                         323           332           +2.79%
BenchmarkFieldFailureParallel-8                                 112           113           +0.89%
BenchmarkFieldDiveSuccess-8                                     719           714           -0.70%
BenchmarkFieldDiveSuccessParallel-8                             230           225           -2.17%
BenchmarkFieldDiveFailure-8                                     1001          987           -1.40%
BenchmarkFieldDiveFailureParallel-8                             323           317           -1.86%
BenchmarkFieldCustomTypeSuccess-8                               263           264           +0.38%
BenchmarkFieldCustomTypeSuccessParallel-8                       82.6          81.4          -1.45%
BenchmarkFieldCustomTypeFailure-8                               327           328           +0.31%
BenchmarkFieldCustomTypeFailureParallel-8                       116           116           +0.00%
BenchmarkFieldOrTagSuccess-8                                    871           878           +0.80%
BenchmarkFieldOrTagSuccessParallel-8                            394           402           +2.03%
BenchmarkFieldOrTagFailure-8                                    568           569           +0.18%
BenchmarkFieldOrTagFailureParallel-8                            397           401           +1.01%
BenchmarkStructLevelValidationSuccess-8                         332           267           -19.58%
BenchmarkStructLevelValidationSuccessParallel-8                 105           82.4          -21.52%
BenchmarkStructLevelValidationFailure-8                         637           557           -12.56%
BenchmarkStructLevelValidationFailureParallel-8                 260           226           -13.08%
BenchmarkStructSimpleCustomTypeSuccess-8                        525           452           -13.90%
BenchmarkStructSimpleCustomTypeSuccessParallel-8                155           144           -7.10%
BenchmarkStructSimpleCustomTypeFailure-8                        828           738           -10.87%
BenchmarkStructSimpleCustomTypeFailureParallel-8                345           285           -17.39%
BenchmarkStructFilteredSuccess-8                                744           664           -10.75%
BenchmarkStructFilteredSuccessParallel-8                        274           257           -6.20%
BenchmarkStructFilteredFailure-8                                595           517           -13.11%
BenchmarkStructFilteredFailureParallel-8                        250           195           -22.00%
BenchmarkStructPartialSuccess-8                                 674           608           -9.79%
BenchmarkStructPartialSuccessParallel-8                         256           225           -12.11%
BenchmarkStructPartialFailure-8                                 928           848           -8.62%
BenchmarkStructPartialFailureParallel-8                         399           360           -9.77%
BenchmarkStructExceptSuccess-8                                  1076          934           -13.20%
BenchmarkStructExceptSuccessParallel-8                          237           200           -15.61%
BenchmarkStructExceptFailure-8                                  873           787           -9.85%
BenchmarkStructExceptFailureParallel-8                          365           333           -8.77%
BenchmarkStructSimpleCrossFieldSuccess-8                        539           489           -9.28%
BenchmarkStructSimpleCrossFieldSuccessParallel-8                201           168           -16.42%
BenchmarkStructSimpleCrossFieldFailure-8                        788           709           -10.03%
BenchmarkStructSimpleCrossFieldFailureParallel-8                322           299           -7.14%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8             795           683           -14.09%
BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel-8     241           211           -12.45%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8             1110          940           -15.32%
BenchmarkStructSimpleCrossStructCrossFieldFailureParallel-8     399           333           -16.54%
BenchmarkStructSimpleSuccess-8                                  367           285           -22.34%
BenchmarkStructSimpleSuccessParallel-8                          108           91.0          -15.74%
BenchmarkStructSimpleFailure-8                                  776           698           -10.05%
BenchmarkStructSimpleFailureParallel-8                          307           284           -7.49%
BenchmarkStructComplexSuccess-8                                 2224          1622          -27.07%
BenchmarkStructComplexSuccessParallel-8                         718           526           -26.74%
BenchmarkStructComplexFailure-8                                 5350          4717          -11.83%
BenchmarkStructComplexFailureParallel-8                         2097          1853          -11.64%
2016-11-15 20:36:34 -05:00
Dean Karn
493dfb6209 correct required tag functionality for pointers, now works like old exists tag. 2016-09-28 10:56:49 -04:00
Dean Karn
506cc5da56 Add Filter logic 2016-09-25 13:48:20 -04:00
Dean Karn
cddc415625 perf enhancements + corrected issue with or's
- or's weren't reporting the param back in the tag, long standing but noticed issue.
- added validation check for or's when more validations exist after the or.
2016-09-19 11:28:38 -04:00
Dean Karn
a7ca4a1d32 add default translations for "en"
- need help creating more.
2016-09-15 14:50:04 -04:00
Dean Karn
532878b008 initial translation/custom error code 2016-09-14 14:48:46 -04:00
joeybloggs
3e196d49c6 saving some bytes uint8 vs int 2016-08-06 20:41:38 -04:00
joeybloggs
b2c8f66e7b why pass the Field names, they already belong to the namespaces... 2016-08-06 20:18:19 -04:00
joeybloggs
6765805f88 continuing perf optimizations 2016-08-06 15:23:45 -04:00
joeybloggs
27b607d6ad avoid a couple of dive allocations 2016-08-06 14:19:33 -04:00
joeybloggs
ecad6333b1 increase dive tag performance. 2016-08-06 13:55:36 -04:00
joeybloggs
dcdba454d7 some variable cleanup 2016-08-05 23:21:09 -04:00
joeybloggs
a8f7aaba72 remove TODO: tried it, only helped with 1 allocation, not worth the overhead and potential contention 2016-08-05 22:34:40 -04:00
joeybloggs
f581a2d517 reuse field 2016-08-05 22:26:20 -04:00
joeybloggs
98dee40973 perf updates all around! 2016-08-05 22:15:08 -04:00
joeybloggs
8c60a612c5 code coverage back to 100% + some code cleanup 2016-08-05 12:34:43 -04:00
joeybloggs
5fedd8c08a buffer errTag + errs array. 2016-08-05 07:15:25 -04:00
joeybloggs
1ff58be284 finish conversion of test + some fixes. 2016-08-04 11:00:01 -04:00
joeybloggs
3bf69e2bbd converting tests 2016-08-03 22:02:47 -04:00
joeybloggs
7e731afde9 field name updates 2016-08-03 19:20:42 -04:00
joeybloggs
e0e1af6a61 working instance 2016-08-03 14:46:35 -04:00
joeybloggs
99a0f5e141 Merge branch 'merge' into minor-perf-merge
# Conflicts:
#	util.go
#	validator.go
#	validator_test.go
2016-07-14 17:06:03 -04:00
joeybloggs
7a080ada5b Fix issue with omitempty combined with nullable types in combination with a default static value set as the value
fix for issue-#249
2016-07-14 16:46:21 -04:00
joeybloggs
43f7b7d61a save some bytes 2016-07-11 14:32:42 -04:00
joeybloggs
4ce4d1cd71 gain another 5% on average by changing tag type from bool's to enum
```

benchmark                                               old ns/op     new ns/op     delta
BenchmarkFieldSuccess-4                                 117           116           -0.85%
BenchmarkFieldFailure-4                                 675           651           -3.56%
BenchmarkFieldDiveSuccess-4                             2518          2418          -3.97%
BenchmarkFieldDiveFailure-4                             3096          3011          -2.75%
BenchmarkFieldCustomTypeSuccess-4                       319           297           -6.90%
BenchmarkFieldCustomTypeFailure-4                       688           680           -1.16%
BenchmarkFieldOrTagSuccess-4                            1251          1176          -6.00%
BenchmarkFieldOrTagFailure-4                            1090          1073          -1.56%
BenchmarkStructLevelValidationSuccess-4                 558           567           +1.61%
BenchmarkStructLevelValidationFailure-4                 608           562           -7.57%
BenchmarkStructSimpleCustomTypeSuccess-4                702           636           -9.40%
BenchmarkStructSimpleCustomTypeFailure-4                1380          1295          -6.16%
BenchmarkStructPartialSuccess-4                         1139          1058          -7.11%
BenchmarkStructPartialFailure-4                         1760          1648          -6.36%
BenchmarkStructExceptSuccess-4                          951           917           -3.58%
BenchmarkStructExceptFailure-4                          1147          1085          -5.41%
BenchmarkStructSimpleCrossFieldSuccess-4                873           783           -10.31%
BenchmarkStructSimpleCrossFieldFailure-4                1478          1384          -6.36%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4     1328          1273          -4.14%
BenchmarkStructSimpleCrossStructCrossFieldFailure-4     1949          1896          -2.72%
BenchmarkStructSimpleSuccess-4                          559           523           -6.44%
BenchmarkStructSimpleFailure-4                          1334          1311          -1.72%
BenchmarkStructSimpleSuccessParallel-4                  148           137           -7.43%
BenchmarkStructSimpleFailureParallel-4                  631           591           -6.34%
BenchmarkStructComplexSuccess-4                         3476          3500          +0.69%
BenchmarkStructComplexFailure-4                         8467          8406          -0.72%
BenchmarkStructComplexSuccessParallel-4                 1098          1012          -7.83%
BenchmarkStructComplexFailureParallel-4                 3113          3121          +0.26%

benchmark                                               old allocs     new allocs     delta
BenchmarkFieldSuccess-4                                 0              0              +0.00%
BenchmarkFieldFailure-4                                 4              4              +0.00%
BenchmarkFieldDiveSuccess-4                             28             28             +0.00%
BenchmarkFieldDiveFailure-4                             32             32             +0.00%
BenchmarkFieldCustomTypeSuccess-4                       2              2              +0.00%
BenchmarkFieldCustomTypeFailure-4                       4              4              +0.00%
BenchmarkFieldOrTagSuccess-4                            1              1              +0.00%
BenchmarkFieldOrTagFailure-4                            6              6              +0.00%
BenchmarkStructLevelValidationSuccess-4                 5              5              +0.00%
BenchmarkStructLevelValidationFailure-4                 5              5              +0.00%
BenchmarkStructSimpleCustomTypeSuccess-4                3              3              +0.00%
BenchmarkStructSimpleCustomTypeFailure-4                9              9              +0.00%
BenchmarkStructPartialSuccess-4                         9              9              +0.00%
BenchmarkStructPartialFailure-4                         14             14             +0.00%
BenchmarkStructExceptSuccess-4                          7              7              +0.00%
BenchmarkStructExceptFailure-4                          9              9              +0.00%
BenchmarkStructSimpleCrossFieldSuccess-4                4              4              +0.00%
BenchmarkStructSimpleCrossFieldFailure-4                9              9              +0.00%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4     7              7              +0.00%
BenchmarkStructSimpleCrossStructCrossFieldFailure-4     12             12             +0.00%
BenchmarkStructSimpleSuccess-4                          1              1              +0.00%
BenchmarkStructSimpleFailure-4                          9              9              +0.00%
BenchmarkStructSimpleSuccessParallel-4                  1              1              +0.00%
BenchmarkStructSimpleFailureParallel-4                  9              9              +0.00%
BenchmarkStructComplexSuccess-4                         15             15             +0.00%
BenchmarkStructComplexFailure-4                         60             60             +0.00%
BenchmarkStructComplexSuccessParallel-4                 15             15             +0.00%
BenchmarkStructComplexFailureParallel-4                 60             60             +0.00%

benchmark                                               old bytes     new bytes     delta
BenchmarkFieldSuccess-4                                 0             0             +0.00%
BenchmarkFieldFailure-4                                 432           432           +0.00%
BenchmarkFieldDiveSuccess-4                             464           464           +0.00%
BenchmarkFieldDiveFailure-4                             896           896           +0.00%
BenchmarkFieldCustomTypeSuccess-4                       32            32            +0.00%
BenchmarkFieldCustomTypeFailure-4                       432           432           +0.00%
BenchmarkFieldOrTagSuccess-4                            4             4             +0.00%
BenchmarkFieldOrTagFailure-4                            448           448           +0.00%
BenchmarkStructLevelValidationSuccess-4                 160           160           +0.00%
BenchmarkStructLevelValidationFailure-4                 160           160           +0.00%
BenchmarkStructSimpleCustomTypeSuccess-4                36            36            +0.00%
BenchmarkStructSimpleCustomTypeFailure-4                640           640           +0.00%
BenchmarkStructPartialSuccess-4                         336           336           +0.00%
BenchmarkStructPartialFailure-4                         794           794           +0.00%
BenchmarkStructExceptSuccess-4                          314           314           +0.00%
BenchmarkStructExceptFailure-4                          336           336           +0.00%
BenchmarkStructSimpleCrossFieldSuccess-4                80            80            +0.00%
BenchmarkStructSimpleCrossFieldFailure-4                536           536           +0.00%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4     112           112           +0.00%
BenchmarkStructSimpleCrossStructCrossFieldFailure-4     576           576           +0.00%
BenchmarkStructSimpleSuccess-4                          4             4             +0.00%
BenchmarkStructSimpleFailure-4                          640           640           +0.00%
BenchmarkStructSimpleSuccessParallel-4                  4             4             +0.00%
BenchmarkStructSimpleFailureParallel-4                  640           640           +0.00%
BenchmarkStructComplexSuccess-4                         244           244           +0.00%
BenchmarkStructComplexFailure-4                         3608          3608          +0.00%
BenchmarkStructComplexSuccessParallel-4                 244           244           +0.00%
BenchmarkStructComplexFailureParallel-4                 3608          3608          +0.00%

```
2016-07-11 13:54:33 -04:00
joeybloggs
330b12dacd Phase 1 optimization complete, Phase 2 ( Warm liquid goo phase ) commencing
Still looking good

```

benchmark                                               old ns/op     new ns/op     delta
BenchmarkFieldSuccess-4                                 167           119           -28.74%
BenchmarkFieldFailure-4                                 701           653           -6.85%
BenchmarkFieldDiveSuccess-4                             2937          2488          -15.29%
BenchmarkFieldDiveFailure-4                             3536          3059          -13.49%
BenchmarkFieldCustomTypeSuccess-4                       341           292           -14.37%
BenchmarkFieldCustomTypeFailure-4                       679           679           +0.00%
BenchmarkFieldOrTagSuccess-4                            1157          1146          -0.95%
BenchmarkFieldOrTagFailure-4                            1109          1063          -4.15%
BenchmarkStructLevelValidationSuccess-4                 694           559           -19.45%
BenchmarkStructLevelValidationFailure-4                 1311          551           -57.97%
BenchmarkStructSimpleCustomTypeSuccess-4                894           641           -28.30%
BenchmarkStructSimpleCustomTypeFailure-4                1496          1302          -12.97%
BenchmarkStructPartialSuccess-4                         1229          1071          -12.86%
BenchmarkStructPartialFailure-4                         1838          1685          -8.32%
BenchmarkStructExceptSuccess-4                          961           927           -3.54%
BenchmarkStructExceptFailure-4                          1218          1068          -12.32%
BenchmarkStructSimpleCrossFieldSuccess-4                954           779           -18.34%
BenchmarkStructSimpleCrossFieldFailure-4                1569          1405          -10.45%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4     1588          1299          -18.20%
BenchmarkStructSimpleCrossStructCrossFieldFailure-4     2217          1917          -13.53%
BenchmarkStructSimpleSuccess-4                          925           519           -43.89%
BenchmarkStructSimpleFailure-4                          1650          1323          -19.82%
BenchmarkStructSimpleSuccessParallel-4                  261           149           -42.91%
BenchmarkStructSimpleFailureParallel-4                  758           543           -28.36%
BenchmarkStructComplexSuccess-4                         5868          3387          -42.28%
BenchmarkStructComplexFailure-4                         10767         8498          -21.07%
BenchmarkStructComplexSuccessParallel-4                 1559          1114          -28.54%
BenchmarkStructComplexFailureParallel-4                 3747          3163          -15.59%

```
2016-07-11 11:39:04 -04:00
joeybloggs
210684a828 code cleanup + add missing tag cache with FieldWith func
Still looking good:

```

benchmark                                               old ns/op     new ns/op     delta
BenchmarkFieldSuccess-4                                 167           119           -28.74%
BenchmarkFieldFailure-4                                 701           650           -7.28%
BenchmarkFieldDiveSuccess-4                             2937          2482          -15.49%
BenchmarkFieldDiveFailure-4                             3536          3046          -13.86%
BenchmarkFieldCustomTypeSuccess-4                       341           296           -13.20%
BenchmarkFieldCustomTypeFailure-4                       679           666           -1.91%
BenchmarkFieldOrTagSuccess-4                            1157          1124          -2.85%
BenchmarkFieldOrTagFailure-4                            1109          1036          -6.58%
BenchmarkStructLevelValidationSuccess-4                 694           554           -20.17%
BenchmarkStructLevelValidationFailure-4                 1311          558           -57.44%
BenchmarkStructSimpleCustomTypeSuccess-4                894           654           -26.85%
BenchmarkStructSimpleCustomTypeFailure-4                1496          1286          -14.04%
BenchmarkStructPartialSuccess-4                         1229          1062          -13.59%
BenchmarkStructPartialFailure-4                         1838          1639          -10.83%
BenchmarkStructExceptSuccess-4                          961           919           -4.37%
BenchmarkStructExceptFailure-4                          1218          1072          -11.99%
BenchmarkStructSimpleCrossFieldSuccess-4                954           800           -16.14%
BenchmarkStructSimpleCrossFieldFailure-4                1569          1372          -12.56%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4     1588          1274          -19.77%
BenchmarkStructSimpleCrossStructCrossFieldFailure-4     2217          1901          -14.25%
BenchmarkStructSimpleSuccess-4                          925           512           -44.65%
BenchmarkStructSimpleFailure-4                          1650          1318          -20.12%
BenchmarkStructSimpleSuccessParallel-4                  261           144           -44.83%
BenchmarkStructSimpleFailureParallel-4                  758           581           -23.35%
BenchmarkStructComplexSuccess-4                         5868          3451          -41.19%
BenchmarkStructComplexFailure-4                         10767         8351          -22.44%
BenchmarkStructComplexSuccessParallel-4                 1559          1065          -31.69%
BenchmarkStructComplexFailureParallel-4                 3747          2916          -22.18%

```
2016-07-11 09:09:25 -04:00
joeybloggs
c0a414dc9e initial un-refined new caching system 2016-07-11 08:53:33 -04:00
joeybloggs
5c8ad6a1a9 only check struct validity once 2016-07-09 16:02:29 -04:00
joeybloggs
f38559b489 Update checking unexpected fields for Go 1.6 https://tip.golang.org/doc/go1.6#reflect
* I have not run into the issue yet, but being preemptive
2016-02-15 20:41:29 -05:00
joeybloggs
0862513fbf Add some string check optimizations
* was using len(string) for some blank checks instead of string == ""
2016-01-06 09:29:50 -05:00
joeybloggs
0b533f264c Only set namespace prefix when using FieldNameTag 2016-01-06 08:46:19 -05:00
joeybloggs
afbcf59553 Add FieldNamespace and NameNamespace
* Add FieldNamespace and NameNamespace to FieldError. This allows for having the CustomName i.e. JSON namespace contained within the NameNamespace which would be very useful when using a more restful API approach.
2016-01-06 08:44:33 -05:00
joeybloggs
e019c28542 Add struct field + associated tags caching
* This essentially reduces the number of cache tag lookups for a structs fields to one.
2015-11-27 15:19:15 -05:00
joeybloggs
94182a2199 init struct cache changes 2015-11-27 10:13:49 -05:00
joeybloggs
b0bd08d7c8 Micro optimization in Tag Cache
Removed defer from the simple Tag Cache lock & unlock and reduced
execution time for even single field validation by almost 100ns
from 254ns/op to 163ns/op .. Not badd for such a simple modification
and this effect ripples throughout struct validation.

```go
$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkFieldSuccess-4                            	10000000 163 ns/op	       0 B/op	       0 allocs/op
BenchmarkFieldFailure-4                            	 2000000 673 ns/op	     400 B/op	       4 allocs/op
BenchmarkFieldDiveSuccess-4                        	  500000 3019 ns/op	     480 B/op	      27 allocs/op
BenchmarkFieldDiveFailure-4                        	  500000 3553 ns/op	     880 B/op	      31 allocs/op
BenchmarkFieldCustomTypeSuccess-4                  	 5000000 347 ns/op	      32 B/op	       2 allocs/op
BenchmarkFieldCustomTypeFailure-4                  	 2000000 645 ns/op	     400 B/op	       4 allocs/op
BenchmarkFieldOrTagSuccess-4                       	 1000000 1177 ns/op	      16 B/op	       1 allocs/op
BenchmarkFieldOrTagFailure-4                       	 1000000 1093 ns/op	     432 B/op	       6 allocs/op
BenchmarkStructLevelValidationSuccess-4            	 2000000 702 ns/op	     160 B/op	       6 allocs/op
BenchmarkStructLevelValidationFailure-4            	 1000000 1279 ns/op	     592 B/op	      11 allocs/op
BenchmarkStructSimpleCustomTypeSuccess-4           	 1000000 1010 ns/op	      80 B/op	       5 allocs/op
BenchmarkStructSimpleCustomTypeFailure-4           	 1000000 1544 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructPartialSuccess-4                    	 1000000 1249 ns/op	     400 B/op	      11 allocs/op
BenchmarkStructPartialFailure-4                    	 1000000 1797 ns/op	     816 B/op	      16 allocs/op
BenchmarkStructExceptSuccess-4                     	 2000000 927 ns/op	     368 B/op	       9 allocs/op
BenchmarkStructExceptFailure-4                     	 1000000 1259 ns/op	     400 B/op	      11 allocs/op
BenchmarkStructSimpleCrossFieldSuccess-4           	 1000000 1076 ns/op	     128 B/op	       6 allocs/op
BenchmarkStructSimpleCrossFieldFailure-4           	 1000000 1623 ns/op	     560 B/op	      11 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4	 1000000 1582 ns/op	     176 B/op	       9 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldFailure-4	 1000000 2139 ns/op	     608 B/op	      14 allocs/op
BenchmarkStructSimpleSuccess-4                     	 1000000 1040 ns/op	      48 B/op	       3 allocs/op
BenchmarkStructSimpleFailure-4                     	 1000000 1683 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructSimpleSuccessParallel-4             	 5000000 356 ns/op	      48 B/op	       3 allocs/op
BenchmarkStructSimpleFailureParallel-4             	 2000000 831 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructComplexSuccess-4                    	  200000 6738 ns/op	     512 B/op	      30 allocs/op
BenchmarkStructComplexFailure-4                    	  200000 11387 ns/op	    3415 B/op	      72 allocs/op
BenchmarkStructComplexSuccessParallel-4            	  500000 2330 ns/op	     512 B/op	      30 allocs/op
BenchmarkStructComplexFailureParallel-4            	  300000 4857 ns/op	    3416 B/op	      72 allocs/op
```

```go
$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkFieldSuccess-4                            	 5000000 254 ns/op	       0 B/op	       0 allocs/op
BenchmarkFieldFailure-4                            	 2000000 779 ns/op	     400 B/op	       4 allocs/op
BenchmarkFieldDiveSuccess-4                        	  500000 3451 ns/op	     480 B/op	      27 allocs/op
BenchmarkFieldDiveFailure-4                        	  300000 3954 ns/op	     880 B/op	      31 allocs/op
BenchmarkFieldCustomTypeSuccess-4                  	 3000000 451 ns/op	      32 B/op	       2 allocs/op
BenchmarkFieldCustomTypeFailure-4                  	 2000000 751 ns/op	     400 B/op	       4 allocs/op
BenchmarkFieldOrTagSuccess-4                       	 1000000 1312 ns/op	      16 B/op	       1 allocs/op
BenchmarkFieldOrTagFailure-4                       	 1000000 1206 ns/op	     432 B/op	       6 allocs/op
BenchmarkStructLevelValidationSuccess-4            	 2000000 829 ns/op	     160 B/op	       6 allocs/op
BenchmarkStructLevelValidationFailure-4            	 1000000 1403 ns/op	     592 B/op	      11 allocs/op
BenchmarkStructSimpleCustomTypeSuccess-4           	 1000000 1238 ns/op	      80 B/op	       5 allocs/op
BenchmarkStructSimpleCustomTypeFailure-4           	 1000000 1771 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructPartialSuccess-4                    	 1000000 1399 ns/op	     400 B/op	      11 allocs/op
BenchmarkStructPartialFailure-4                    	 1000000 1926 ns/op	     816 B/op	      16 allocs/op
BenchmarkStructExceptSuccess-4                     	 2000000 930 ns/op	     368 B/op	       9 allocs/op
BenchmarkStructExceptFailure-4                     	 1000000 1381 ns/op	     400 B/op	      11 allocs/op
BenchmarkStructSimpleCrossFieldSuccess-4           	 1000000 1253 ns/op	     128 B/op	       6 allocs/op
BenchmarkStructSimpleCrossFieldFailure-4           	 1000000 1849 ns/op	     560 B/op	      11 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4	 1000000 1902 ns/op	     176 B/op	       9 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldFailure-4	  500000 2453 ns/op	     608 B/op	      14 allocs/op
BenchmarkStructSimpleSuccess-4                     	 1000000 1182 ns/op	      48 B/op	       3 allocs/op
BenchmarkStructSimpleFailure-4                     	 1000000 1842 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructSimpleSuccessParallel-4             	 5000000 342 ns/op	      48 B/op	       3 allocs/op
BenchmarkStructSimpleFailureParallel-4             	 2000000 665 ns/op	     624 B/op	      11 allocs/op
BenchmarkStructComplexSuccess-4                    	  200000 7924 ns/op	     512 B/op	      30 allocs/op
BenchmarkStructComplexFailure-4                    	  100000 12605 ns/op	    3415 B/op	      72 allocs/op
BenchmarkStructComplexSuccessParallel-4            	 1000000 2421 ns/op	     512 B/op	      30 allocs/op
BenchmarkStructComplexFailureParallel-4            	  300000 4234 ns/op	    3416 B/op	      72 allocs/op
```
2015-11-26 08:37:14 -05:00
joeybloggs
cab69bdd13 Add minor optimization for structonly & nostructlevel checks 2015-11-20 09:01:22 -05:00
joeybloggs
24c1c6819f Add nostructlevel tag
* nostructlevel - Same as structonly tag except that any struct level
		  validations will not run.
2015-11-19 16:43:52 -05:00