Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module bluesuncorp/validator to v9 #7

Merged
merged 1 commit into from
Aug 31, 2019

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Aug 25, 2019

This PR contains the following updates:

Package Type Update Change
gopkg.in/bluesuncorp/validator.v5 require major v5.10.3 -> v9.29.1

Release Notes

bluesuncorp/validator

v9.29.1

Compare Source

What was fixed?

v9.29.0

Compare Source

What's new?
  • Updated the hostname regex to support uppercase letters, thanks @​Zeroen for the PR

Some new and exciting validators have been added, thanks @​mashmooli for the PR

  • required_with
  • required_with_all
  • required_without
  • required_without_all

please see the docs for usage instructions!

v9.28.0

Compare Source

What's new?

Huge shout out to the community for all the help!

  • Added new section for non-standard validations here from PR, thanks @​andreiavrammsd!
    • these non standard validations will not be part of the beked in validations but rather a place for the community to put one-off validations that others may find useful and can register them as needed.
  • Updsated the SSN regex to handle more use cases in PR, thanks @​rucas!
  • Added startswith snd endswith validations in PR, thanks @​thcipriani!
  • Fixed a typo in the struct level example in PR, thanks @​masseelch!
  • Updated the docs to include the uuid_rfc4122 validations in PR, thanks @​alexbilbie!
  • Updated the email validations regex to handle a couple of failing real-world cases in PR, thanks @​benpaxton-hf!

v9.27.0

Compare Source

What new?

v9.26.0

Compare Source

What's new?

Added uuid rfc4122 validation, thanks @​rssathe for the PR!

v9.25.0

Compare Source

What's new?

Add baked in validators for containsfield and excludesfield, thanks @​fharding1 for the PR

What was fixed

Fixed Japanese translations, thanks @​akm for the PR

v9.24.0

Compare Source

What's new?
  • Added URN validation, thanks @​leodido for the PR
  • Added Japanese translations!!! 😍 , thanks @​akm for the PR
What was fixed?
  • Corrected imports in the pt_BR translation, thanks @​AGPDev for the PR
  • Added missing translation for unique validation, thanks @​holyspectral for the PR

v9.23.0

Compare Source

What's new?

v9.22.0

Compare Source

What's new?
  • Added better RegisterTagNameFunc documentation in this PR, thanks @​frou for the PR!
  • Added zh-tw translations in this PR, thanks @​kanozec for the PR!

v9.21.1

Compare Source

What was fixed?

Corrected some documentation in this PR and this PR; thanks @​44px & @​sakura1116vg for the PR's!

v9.21.0

Compare Source

What's new?

Added dutch translations thanks to @​wesselvanderlinden and PR #​387!

v9.20.2

Compare Source

What was fixed?

Corrected language package name thanks @​foolin , wee #​381 for details.

v9.20.1

Compare Source

What was fixed?
  • corrected StructFilteredCtx not passing the context through, thanks @​dvic!, see #​380 for details.

v9.20.0

Compare Source

What's new?

Added Chinese translations, thanks @​foolin! for more details foor #​379

v9.19.0

Compare Source

What's new?

3 new validations added:

html - This validates that a string value appears to be an HTML element tag including those described at https://developer.mozilla.org/en-US/docs/Web/HTML/Element

html_encoded - This validates that a string value is a proper character reference in decimal or hexadecimal format

url_encoded - This validates that a string value is percent-encoded (URL encoded) according to https://tools.ietf.org/html/rfc3986#section-2.1

for details see PR #​377 Thanks @​heatwole for the PR!

v9.17.1

Compare Source

What was fixed

A typo in the documentation, thanks @​tengis617 for the PR

v9.17.0

Compare Source

Expanded numeric & number validations

It was originally intended for these to only be used on strings, however
it makes sense to also use them if you are dealing with type interface{}

So now ints and floats return true for this validation also as they are
both numeric and a number.

v9.16.1

Compare Source

What was fixed?

According to http://www.ietf.org/rfc/rfc1123.txt Hostnames are limited to letters-digits-hyphen, removing underscore as a valid character. see PR #​359 for details. Thanks @​jadhub for the PR! & @​danielpoe for reporting.

v9.16.0

Compare Source

What's new?
  • Update gin upgrade example, see #​358 for details, thanks @​Ashtonian for the PR!
  • Extended the unique tag to also cover map values, see #​361 for details, thanks @​jservice-rvbd for the PR!
  • cleaned up some linting and spelling errors.
    • fixed some translation error checks not propogated found during linting.

v9.15.0

Compare Source

What's new

Add the following new validations:

  • Adds bitcoin address validation for P2PKH and P2SH addresses
  • Adds bitcoin address validation for Bech32 addresses
  • Adds basic ethereum address validation

Thanks @​QuestofIranon for the PR

v9.14.0

Compare Source

What's new?

Added base64url validation according to section 5 of RFC4648 Thanks @​kgeorgiou for the PR!

v9.13.0

Compare Source

What's New?

Added Brazilian Portuguese translations see PR #​350 Thanks @​afranioce

v9.12.0

Compare Source

What's new?
  • French translations were added for error messages thanks to @​fdelbos's PR

v9.11.0

Compare Source

What's new?

added a new validation oneof thanks for the PR @​ansel1

see details in the PR go-playground#​343

v9.10.0

Compare Source

What's new?

Added new validation hostname_rfc1123 the current hostname validation is for RFC 952

###I want to use the new hostname validation, but don't want to go around and change my struct tags.
No problem, just register an Alias eg.

validate := validator.New()
validate.RegisterAlias("hostname", "hostname_rfc1123")

v9.9.4

Compare Source

What was fixed?

  • Corrected docs for method name change FieldWithValue => VarWithValue
  • Corrected display of translations when field is relfect.Ptr thanks @​glb see #​340

v9.9.3

Compare Source

What was fixed?

Update tagCache locking scope to allow for validate.Var and validate.VarCtx to be used from within validations functions. see #​335 for details.

v9.9.2

Compare Source

What was fixed/updated?

Updated docs to clarify between validation tag separator or , and or validation tag separator |

v9.9.1

Compare Source

What was fixed?

There was an issue checking for the end of an or validation block and when 2 consecutive or validation blocks existed, it would not return an error or return an incorrect error.

NOTE: This bug only affected validation with consecutive or validation blocks eg.

validate:"tag1|tag2=,tag3|tag4"

block1 = tag1|tag2=
block2 = tag3|tag4

Thanks for reporting the issue @​skryja, see #​329 for more details

v9.9.0

Compare Source

What's new?

Added map key validation support with new keys and endkeys eg.

type Test struct {
  Map map[string]string `validate:"dive,keys,trim,endkeys,trim"`
}

keys must be directly after the dive tag; this was done for efficiency to allow map keys and values to be be handled within the same range.

see docs for more details.

v9.8.0

Compare Source

What was added?

Added unique validation for ensuring array|slice contain unique values.

v9.7.0

Compare Source

Whats New?

Added new isdefault tag, essentially it's the opposite of required and only intended for specific use cases. See #​299 for more details.

What was fixed?

Corrected error in fqdn when value is blank, see #​306 for more details.

v9.6.0

Compare Source

What's new?

Added hostname and fqdn validations thanks to @​senuphtyz and PR #​298

v9.5.0

Compare Source

What new?

Added contextual validation support via context.Context: thanks to @​thaonx @​nuxier and PR #​292

  • RegisterValidationCtx(...)
  • RegisterStructValidationCtx(...)
  • StructCtx(...)
  • StructFilteredCtx(...)
  • StructPartialCtx(...)
  • StructExceptCtx(...)
  • VarCtx(...)
  • VarWithValueCtx(...)

NOTE: in v10 release all old methods will be removed and only new Context methods will remain.

v9.4.0

Compare Source

What's new?
  • Add Access to Field Name from FieldLevel interface via FieldLevel.FieldName() and FieldLevel.StructFieldName()
  • Renamed examples directory to _examples to avoid any potential dependencies in examples being pulled in by go tools.

v9.3.6

Compare Source

What was fixed?

  • Some more typos in the documentation.
  • Updated README to fix rendering issue with GitHub's new markdown parser.

v9.3.5

Compare Source

What was fixed?
  • Corrected some typos in README which Fixes #​273
  • updated lint issue in one of the tests
  • Updated Benchmarks for Go 1.8

v9.3.4

Compare Source

What was fixed?

no issues with validator, just updating test.

  • Updated failing test for new translation error message.
  • Updated benchmarks with my new dev machine at the same time.

v9.3.3

Compare Source

What was fixed?

v9.3.2

Compare Source

What was fixed?

Corrected Namespace issue when a field within an array or map of structs causes an error, see #​266

Thanks @​cbandy for reporting!

v9.3.1

Compare Source

What was fixed?

structonly did not behave as expected when not accompanied by a struct validation thanks @​thessem for reporting in #​264 😄

v9.3.0

Compare Source

What was added?
  • added alphaunicode and alphanumunicode validations which are basically just unicode variants of the alpha and alphanum validations that were ASCII only.

relates to #​261

v9.2.2

Compare Source

What was fixed

update cached fields to be stored in array instead of map for #​260 thanks @​jonmchan for reporting

  • errors now always print out in order for tests
  • performance enhancement from array vs map is nice too ;)
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%

v9.2.1

Compare Source

What was fixed?

The required tag was not correctly validating pointer fields like the old v8 exists tag ( see issue #​142 ) was and so that bug has been corrected. thanks @​codepushr for reporting

  • added required tag to the restricted tags that cannot be overridden because of it's dual functionality with pointers ( thought it already was, my mistake )

v9.2.0

Compare Source

What's new?

Added StructFiltered(s interface{}, fn FilterFunc) function to allow for better filtering of fields besides StructPartial or StructExcept for #​255

thanks @​jawher for the idea

v9.1.3

Compare Source

What was fixed?

Explicitly qualify universal-translator imports; thanks @​jawher

v9.1.2

Compare Source

What was fixed?
  • accidentally cut a release before changes were pushed, fix release for v9.1.1; apologies for the noise.

v9.1.1

Compare Source

What was fixed?
  • added missing iscolor alias translation
  • correct 2 issues with or's
    • param wasn't being set on the returned or tag eg. rgb|rgba|len=10 was missing the =10 when reporting the tag in error
    • corrected issue when tags may exist past the or's as a double check, nobody has ever run into this but I did adding some new functionality not yet released, and wanted to add it in now for the future.

v9.1.0

Compare Source

What's New?

🎉 This change has been a long time coming 🎉

The story so far....

A long time ago in a validator package on a github server far far away...

A request was made for allowing custom validations #​174 but the evil i18n,

localization of errors, stood in our way #​230. An expedition was dispatched to

search the vastness open source, but alas no suitable i18n package with correct

pluralization rules could be found; the outlook for validator seemed grim; until a

developer created an i18n and l10n helper package locales and an i18n package

universal-translator that wraps it and then jammed that functionality deep inside of validator!

So without further ado:
  • Added i18n aware Custom Error Message translations see here for an example
    • Custom Translation can be registered using RegisterTranslation
    • A Default set of translations exists for the en locale here; if anyone could help in adding more for other locales that would be appreciated 😄

v9.0.0

Compare Source

Release 9.0.0

After much work, tweaking and design updates validator v9 has been released!

It's even faster, more efficient and built for ease of use!

Quick overview of changes

documentation has been updated to reflect all of these changes, see them for more details.

  • ValidationErrors is now an []FieldError instead of a map as before.
  • exists tag has been removed, now required tag handles pointer values as well.
  • Much of the design has been updated to use interfaces allowing for even less breaking changes going forward, including FieldError.
  • change name for validating individual fields, I think that some people were associating validation using validate.Field or validate.FieldWithValue to a struct field only, but that is not the case, any variable can be validated and so the functions have been changed to:
var age int

err := validate.Var(age, "gte=0,lte=130")

var parentsAge int

err := validate.VarWithValue(age, parentsAge, "ltcsfield")

// side note: reason validator doesn't have strict sanitizers like IsEmail(..) bool is so many validation can be run  on a field in one run eg.

var settings []string

// this will validate that settings exists, there is at least one entry in array 
// and that each string within the array is set...
validate.Var(settings, "required,gte=1,dive,required")
  • can register any custom tag name function instead of before having to specify the name of the tag...
validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
    name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]

    if name == "-" {
        return ""
    }

    return name
})
  • Validation function + Struct Level validation function signatures have changed to use interface and should be infinity easier to remember and implement:
// field level validation func
type Func func(fl FieldLevel) bool

// struct level validation func
type StructLevelFunc func(sl StructLevel)
And now what veryone wants to see, benchmarks compared to v8
benchmark                                               old ns/op     new ns/op     delta
BenchmarkFieldSuccess-8                                 118           108           -8.47%
BenchmarkFieldFailure-8                                 758           320           -57.78%
BenchmarkFieldDiveSuccess-8                             2471          726           -70.62%
BenchmarkFieldDiveFailure-8                             3172          939           -70.40%
BenchmarkFieldCustomTypeSuccess-8                       300           268           -10.67%
BenchmarkFieldCustomTypeFailure-8                       775           310           -60.00%
BenchmarkFieldOrTagSuccess-8                            1122          889           -20.77%
BenchmarkFieldOrTagFailure-8                            1167          546           -53.21%
BenchmarkStructLevelValidationSuccess-8                 548           336           -38.69%
BenchmarkStructLevelValidationFailure-8                 558           611           +9.50%
BenchmarkStructSimpleCustomTypeSuccess-8                623           555           -10.91%
BenchmarkStructSimpleCustomTypeFailure-8                1381          811           -41.27%
BenchmarkStructPartialSuccess-8                         1036          676           -34.75%
BenchmarkStructPartialFailure-8                         1734          1001          -42.27%
BenchmarkStructExceptSuccess-8                          888           1038          +16.89%
BenchmarkStructExceptFailure-8                          1036          863           -16.70%
BenchmarkStructSimpleCrossFieldSuccess-8                773           549           -28.98%
BenchmarkStructSimpleCrossFieldFailure-8                1487          783           -47.34%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     1261          837           -33.62%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     2055          1110          -45.99%
BenchmarkStructSimpleSuccess-8                          519           380           -26.78%
BenchmarkStructSimpleFailure-8                          1429          760           -46.82%
BenchmarkStructSimpleSuccessParallel-8                  146           114           -21.92%
BenchmarkStructSimpleFailureParallel-8                  551           353           -35.93%
BenchmarkStructComplexSuccess-8                         3269          2100          -35.76%
BenchmarkStructComplexFailure-8                         8436          5080          -39.78%
BenchmarkStructComplexSuccessParallel-8                 1024          662           -35.35%
BenchmarkStructComplexFailureParallel-8                 3536          2159          -38.94%

benchmark                                               old allocs     new allocs     delta
BenchmarkFieldSuccess-8                                 0              0              +0.00%
BenchmarkFieldFailure-8                                 4              4              +0.00%
BenchmarkFieldDiveSuccess-8                             28             11             -60.71%
BenchmarkFieldDiveFailure-8                             32             16             -50.00%
BenchmarkFieldCustomTypeSuccess-8                       2              2              +0.00%
BenchmarkFieldCustomTypeFailure-8                       4              4              +0.00%
BenchmarkFieldOrTagSuccess-8                            1              1              +0.00%
BenchmarkFieldOrTagFailure-8                            6              5              -16.67%
BenchmarkStructLevelValidationSuccess-8                 5              2              -60.00%
BenchmarkStructLevelValidationFailure-8                 5              8              +60.00%
BenchmarkStructSimpleCustomTypeSuccess-8                3              2              -33.33%
BenchmarkStructSimpleCustomTypeFailure-8                9              9              +0.00%
BenchmarkStructPartialSuccess-8                         9              6              -33.33%
BenchmarkStructPartialFailure-8                         14             11             -21.43%
BenchmarkStructExceptSuccess-8                          7              12             +71.43%
BenchmarkStructExceptFailure-8                          9              10             +11.11%
BenchmarkStructSimpleCrossFieldSuccess-8                4              3              -25.00%
BenchmarkStructSimpleCrossFieldFailure-8                9              8              -11.11%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     7              4              -42.86%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     12             9              -25.00%
BenchmarkStructSimpleSuccess-8                          1              0              -100.00%
BenchmarkStructSimpleFailure-8                          9              9              +0.00%
BenchmarkStructSimpleSuccessParallel-8                  1              0              -100.00%
BenchmarkStructSimpleFailureParallel-8                  9              9              +0.00%
BenchmarkStructComplexSuccess-8                         15             8              -46.67%
BenchmarkStructComplexFailure-8                         60             53             -11.67%
BenchmarkStructComplexSuccessParallel-8                 15             8              -46.67%
BenchmarkStructComplexFailureParallel-8                 60             53             -11.67%

benchmark                                               old bytes     new bytes     delta
BenchmarkFieldSuccess-8                                 0             0             +0.00%
BenchmarkFieldFailure-8                                 432           192           -55.56%
BenchmarkFieldDiveSuccess-8                             464           201           -56.68%
BenchmarkFieldDiveFailure-8                             896           396           -55.80%
BenchmarkFieldCustomTypeSuccess-8                       32            32            +0.00%
BenchmarkFieldCustomTypeFailure-8                       432           192           -55.56%
BenchmarkFieldOrTagSuccess-8                            4             16            +300.00%
BenchmarkFieldOrTagFailure-8                            448           208           -53.57%
BenchmarkStructLevelValidationSuccess-8                 160           32            -80.00%
BenchmarkStructLevelValidationFailure-8                 160           288           +80.00%
BenchmarkStructSimpleCustomTypeSuccess-8                36            32            -11.11%
BenchmarkStructSimpleCustomTypeFailure-8                640           392           -38.75%
BenchmarkStructPartialSuccess-8                         272           256           -5.88%
BenchmarkStructPartialFailure-8                         730           464           -36.44%
BenchmarkStructExceptSuccess-8                          250           480           +92.00%
BenchmarkStructExceptFailure-8                          272           448           +64.71%
BenchmarkStructSimpleCrossFieldSuccess-8                80            72            -10.00%
BenchmarkStructSimpleCrossFieldFailure-8                536           288           -46.27%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     112           80            -28.57%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     576           304           -47.22%
BenchmarkStructSimpleSuccess-8                          4             0             -100.00%
BenchmarkStructSimpleFailure-8                          640           392           -38.75%
BenchmarkStructSimpleSuccessParallel-8                  4             0             -100.00%
BenchmarkStructSimpleFailureParallel-8                  640           392           -38.75%
BenchmarkStructComplexSuccess-8                         244           128           -47.54%
BenchmarkStructComplexFailure-8                         3609          2833          -21.50%
BenchmarkStructComplexSuccessParallel-8                 244           128           -47.54%
BenchmarkStructComplexFailureParallel-8                 3609          2833          -21.50%

v8.18.2

Compare Source

What was fixed?

Backported some test fixes to solve false positives

v8.18.1

Compare Source

What was Fixed?
  • corrected some spelling mistakes in the docs, that is all.

v8.18.0

Compare Source

What's New?
  • Nothing, some backend performance updates, free of charge!
benchmark                                               old ns/op     new ns/op     delta
BenchmarkFieldSuccess-8                                 155           118           -23.87%
BenchmarkFieldFailure-8                                 777           758           -2.45%
BenchmarkFieldDiveSuccess-8                             2813          2471          -12.16%
BenchmarkFieldDiveFailure-8                             3544          3172          -10.50%
BenchmarkFieldCustomTypeSuccess-8                       328           300           -8.54%
BenchmarkFieldCustomTypeFailure-8                       748           775           +3.61%
BenchmarkFieldOrTagSuccess-8                            1169          1122          -4.02%
BenchmarkFieldOrTagFailure-8                            1205          1167          -3.15%
BenchmarkStructLevelValidationSuccess-8                 670           548           -18.21%
BenchmarkStructLevelValidationFailure-8                 1380          558           -59.57%
BenchmarkStructSimpleCustomTypeSuccess-8                889           623           -29.92%
BenchmarkStructSimpleCustomTypeFailure-8                1536          1381          -10.09%
BenchmarkStructPartialSuccess-8                         1194          1036          -13.23%
BenchmarkStructPartialFailure-8                         1869          1734          -7.22%
BenchmarkStructExceptSuccess-8                          949           888           -6.43%
BenchmarkStructExceptFailure-8                          1181          1036          -12.28%
BenchmarkStructSimpleCrossFieldSuccess-8                948           773           -18.46%
BenchmarkStructSimpleCrossFieldFailure-8                1708          1487          -12.94%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     1608          1261          -21.58%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     2320          2055          -11.42%
BenchmarkStructSimpleSuccess-8                          833           519           -37.70%
BenchmarkStructSimpleFailure-8                          1612          1429          -11.35%
BenchmarkStructSimpleSuccessParallel-8                  239           146           -38.91%
BenchmarkStructSimpleFailureParallel-8                  664           551           -17.02%
BenchmarkStructComplexSuccess-8                         5025          3269          -34.95%
BenchmarkStructComplexFailure-8                         10166         8436          -17.02%
BenchmarkStructComplexSuccessParallel-8                 1591          1024          -35.64%
BenchmarkStructComplexFailureParallel-8                 4306          3536          -17.88%

benchmark                                               old allocs     new allocs     delta
BenchmarkFieldSuccess-8                                 0              0              +0.00%
BenchmarkFieldFailure-8                                 4              4              +0.00%
BenchmarkFieldDiveSuccess-8                             27             28             +3.70%
BenchmarkFieldDiveFailure-8                             31             32             +3.23%
BenchmarkFieldCustomTypeSuccess-8                       2              2              +0.00%
BenchmarkFieldCustomTypeFailure-8                       4              4              +0.00%
BenchmarkFieldOrTagSuccess-8                            1              1              +0.00%
BenchmarkFieldOrTagFailure-8                            6              6              +0.00%
BenchmarkStructLevelValidationSuccess-8                 6              5              -16.67%
BenchmarkStructLevelValidationFailure-8                 11             5              -54.55%
BenchmarkStructSimpleCustomTypeSuccess-8                5              3              -40.00%
BenchmarkStructSimpleCustomTypeFailure-8                11             9              -18.18%
BenchmarkStructPartialSuccess-8                         10             9              -10.00%
BenchmarkStructPartialFailure-8                         15             14             -6.67%
BenchmarkStructExceptSuccess-8                          7              7              +0.00%
BenchmarkStructExceptFailure-8                          10             9              -10.00%
BenchmarkStructSimpleCrossFieldSuccess-8                6              4              -33.33%
BenchmarkStructSimpleCrossFieldFailure-8                11             9              -18.18%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     10             7              -30.00%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     15             12             -20.00%
BenchmarkStructSimpleSuccess-8                          3              1              -66.67%
BenchmarkStructSimpleFailure-8                          11             9              -18.18%
BenchmarkStructSimpleSuccessParallel-8                  3              1              -66.67%
BenchmarkStructSimpleFailureParallel-8                  11             9              -18.18%
BenchmarkStructComplexSuccess-8                         32             15             -53.12%
BenchmarkStructComplexFailure-8                         77             60             -22.08%
BenchmarkStructComplexSuccessParallel-8                 32             15             -53.12%
BenchmarkStructComplexFailureParallel-8                 77             60             -22.08%

benchmark                                               old bytes     new bytes     delta
BenchmarkFieldSuccess-8                                 0             0             +0.00%
BenchmarkFieldFailure-8                                 432           432           +0.00%
BenchmarkFieldDiveSuccess-8                             384           464           +20.83%
BenchmarkFieldDiveFailure-8                             816           896           +9.80%
BenchmarkFieldCustomTypeSuccess-8                       32            32            +0.00%
BenchmarkFieldCustomTypeFailure-8                       432           432           +0.00%
BenchmarkFieldOrTagSuccess-8                            4             4             +0.00%
BenchmarkFieldOrTagFailure-8                            448           448           +0.00%
BenchmarkStructLevelValidationSuccess-8                 168           160           -4.76%
BenchmarkStructLevelValidationFailure-8                 632           160           -74.68%
BenchmarkStructSimpleCustomTypeSuccess-8                56            36            -35.71%
BenchmarkStructSimpleCustomTypeFailure-8                656           640           -2.44%
BenchmarkStructPartialSuccess-8                         352           272           -22.73%
BenchmarkStructPartialFailure-8                         808           730           -9.65%
BenchmarkStructExceptSuccess-8                          314           250           -20.38%
BenchmarkStructExceptFailure-8                          352           272           -22.73%
BenchmarkStructSimpleCrossFieldSuccess-8                96            80            -16.67%
BenchmarkStructSimpleCrossFieldFailure-8                552           536           -2.90%
BenchmarkStructSimpleCrossStructCrossFieldSuccess-8     136           112           -17.65%
BenchmarkStructSimpleCrossStructCrossFieldFailure-8     600           576           -4.00%
BenchmarkStructSimpleSuccess-8                          24            4             -83.33%
BenchmarkStructSimpleFailure-8                          656           640           -2.44%
BenchmarkStructSimpleSuccessParallel-8                  24            4             -83.33%
BenchmarkStructSimpleFailureParallel-8                  656           640           -2.44%
BenchmarkStructComplexSuccess-8                         392           244           -37.76%
BenchmarkStructComplexFailure-8                         3745          3609          -3.63%
BenchmarkStructComplexSuccessParallel-8                 392           244           -37.76%
BenchmarkStructComplexFailureParallel-8                 3745          3609          -3.63%

v8.17.3

Compare Source

What was Fixed?
  • Fix issue when using omitempty combined with a nullable type in combination with a default static value set as the value ( quite a mouthful right ) see issue #​249 for details, thanks @​robbrockbank for reporting!

in summary, it's a very specific issue, update is recommended, and nothing else required.

v8.17.2

Compare Source

What Changed?
  • Corrected a couple typos in the documentation thanks to @​kenkouot

v8.17.1

Compare Source

Go 1.6 changes required updates

Update validations for "url" and "uri" because of Go 1.6 changes

Issue

Go 1.6 change golang/go@617c93c (comment)

Fix

fix was to emulate browser and strip the '#' suffix prior to validation. see #​237

Thanks @​kbalonek for reporting

v8.15.1

Compare Source

Documentation changes
  • Updated godocs for better readability thanks @​aarongreenlee for the pull request!
  • Added "Complimentary Software" section to the README for other libraries that could also help out.

v8.8.1

Compare Source

Fix issue with structOnly + struct level validation
  • when "structonly" tag was set the struct
    level validation wasn't running, this has been corrected.

v8.0.1

Compare Source

What v8 Why?
  • v8 was needed to update a bunch of code to basically spit polish this library. READ more below for details.
  • Added Tag alias logic.
Changes
  • Validator now returns type error instead of type ValidationErrors, this was due to some confusion about interfaces and them never being nil and hence the error, is some situations would never be nil either. This change actually now behaves a little more like packages in the standard library, for example: https://golang.org/pkg/os/#Open file.Open returns nil if everything is ok and *PathError if not; now this library return nil if no errors and ValidationErrors if there are. to type cast just do this to the returned error err.(validator.ValidationErrors) for a more detailed explanation of why this change was made see the following issue and post:
  • BakedInValidators is no longer exposed; it allowed for the map to be manipulated externally, potentially while validator was running, which could cause unknown issues. baked in validators are now automatically added when creating a new validator.
  • You can no longer pass a map of validation functions when creating a new validator instance; now you must use the register function RegisterValidation https://godoc.org/gopkg.in/bluesuncorp/validator.v8#Validate.RegisterValidation
  • Now validating custom tags when adding new validations to ensure core tags that are needed for the library to operate correctly are not overwritten and that invalid characters are not present.
  • Config is now passed in as a pointer when initializing a new instance.
What do I need to change to update?

not that much

// for Config
//before
config := validator.Config{TagName:"validate", Validators: validator.BakedInValidators}
// now
config := &validator.Config{TagName:"validate"}

// for getting at individual FieldError's within the ValidationErrors map
// before
errs := validate.Struct(mystruct)
if errs != nil {
  range k, fieldError := range errs {
    // build your own error message
  }
}

// now
errs := validate.Struct(mystruct)
if errs != nil {
  range k, fieldError := range errs.(validator.ValidationErrors) {
    // build your own error message
  }
}
Additions
  • Added ability to add a validation tag that map to a predefined set of validations; maybe because you use it allot, or want to be able to update globally. For example there is one default alias validator baked in, the tag is "iscolor" and when validator see's that tag on the struct it runs the following validations "hexcolor|rgb|rgba|hsl|hsla". NOTE: when an error occurs you will get the aliased error i.e. "iscolor"; the only exception is the "dive" tag. Any validations defined after a "dive" tag returns the actual validation tag, the reason for this is that not tag can apply to both the top level and a sub element, say of a slice, without being defined twice; the same rule applied for alias. This is documented in detail within the godocs https://godoc.org/gopkg.in/bluesuncorp/validator.v8
New Benchmarks

ns/op changed ever so slightly, but the minor tradeoff for ability to use alias is well worth it.

$ go test -cpu=4 -bench=. -benchmem=true
PASS
BenchmarkFieldSuccess-4                              5000000           296 ns/op          16 B/op          1 allocs/op
BenchmarkFieldFailure-4                              5000000           294 ns/op          16 B/op          1 allocs/op
BenchmarkFieldDiveSuccess-4                           500000          2529 ns/op         384 B/op         19 allocs/op
BenchmarkFieldDiveFailure-4                           500000          3056 ns/op         768 B/op         23 allocs/op
BenchmarkFieldCustomTypeSuccess-4                    3000000           443 ns/op          32 B/op          2 allocs/op
BenchmarkFieldCustomTypeFailure-4                    2000000           753 ns/op         384 B/op          4 allocs/op
BenchmarkFieldOrTagSuccess-4                         1000000          1334 ns/op          32 B/op          2 allocs/op
BenchmarkFieldOrTagFailure-4                         1000000          1172 ns/op         416 B/op          6 allocs/op
BenchmarkStructSimpleCustomTypeSuccess-4             1000000          1206 ns/op          80 B/op          5 allocs/op
BenchmarkStructSimpleCustomTypeFailure-4             1000000          1737 ns/op         592 B/op         11 allocs/op
BenchmarkStructPartialSuccess-4                      1000000          1367 ns/op         400 B/op         11 allocs/op
BenchmarkStructPartialFailure-4                      1000000          1914 ns/op         800 B/op         16 allocs/op
BenchmarkStructExceptSuccess-4                       2000000           909 ns/op         368 B/op          9 allocs/op
BenchmarkStructExceptFailure-4                       1000000          1350 ns/op         400 B/op         11 allocs/op
BenchmarkStructSimpleCrossFieldSuccess-4             1000000          1218 ns/op         128 B/op          6 allocs/op
BenchmarkStructSimpleCrossFieldFailure-4             1000000          1783 ns/op         544 B/op         11 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldSuccess-4  1000000          1806 ns/op         160 B/op          8 allocs/op
BenchmarkStructSimpleCrossStructCrossFieldFailure-4  1000000          2369 ns/op         576 B/op         13 allocs/op
BenchmarkStructSimpleSuccess-4                       1000000          1161 ns/op          48 B/op          3 allocs/op
BenchmarkStructSimpleFailure-4                       1000000          1813 ns/op         592 B/op         11 allocs/op
BenchmarkStructSimpleSuccessParallel-4               5000000           353 ns/op          48 B/op          3 allocs/op
BenchmarkStructSimpleFailureParallel-4               2000000           656 ns/op         592 B/op         11 allocs/op
BenchmarkStructComplexSuccess-4                       200000          7637 ns/op         432 B/op         27 allocs/op
BenchmarkStructComplexFailure-4                       100000         12775 ns/op        3128 B/op         69 allocs/op
BenchmarkStructComplexSuccessParallel-4              1000000          2270 ns/op         432 B/op         27 allocs/op
BenchmarkStructComplexFailureParallel-4               300000          4328 ns/op        3128 B/op         69 allocs/op
Author Notes

I know that I have created a few new versions lately and just wanted to touch on that.

  • I only c

Renovate configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻️ Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "rebase!".

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot. View repository job log here.

@renovate renovate bot force-pushed the renovate/gopkg.in-bluesuncorp-validator.v5-9.x branch 30 times, most recently from 6c48eaf to 28c65f9 Compare August 27, 2019 02:55
@renovate renovate bot force-pushed the renovate/gopkg.in-bluesuncorp-validator.v5-9.x branch 26 times, most recently from 77c8cf9 to d7795ac Compare August 31, 2019 14:31
@renovate renovate bot force-pushed the renovate/gopkg.in-bluesuncorp-validator.v5-9.x branch from d7795ac to b494935 Compare August 31, 2019 14:32
@alphaolomi alphaolomi merged commit 798b922 into master Aug 31, 2019
@renovate renovate bot deleted the renovate/gopkg.in-bluesuncorp-validator.v5-9.x branch August 31, 2019 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants