From 0130415c3fb3978fd4f7495b73ca352c3e849973 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:03:30 +0000 Subject: [PATCH] chore(deps): bump github.com/go-playground/validator/v10 Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.24.0 to 10.26.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.24.0...v10.26.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-version: 10.26.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../validator/v10/.golangci.yaml | 102 ++++++++++++++++++ .../go-playground/validator/v10/Makefile | 2 +- .../go-playground/validator/v10/README.md | 6 +- .../go-playground/validator/v10/baked_in.go | 51 +++++++-- .../go-playground/validator/v10/cache.go | 7 +- .../go-playground/validator/v10/doc.go | 8 +- .../go-playground/validator/v10/regexes.go | 4 +- .../validator/v10/struct_level.go | 6 +- .../go-playground/validator/v10/validator.go | 17 +++ .../validator/v10/validator_instance.go | 1 + vendor/modules.txt | 2 +- 13 files changed, 190 insertions(+), 22 deletions(-) create mode 100644 vendor/github.com/go-playground/validator/v10/.golangci.yaml diff --git a/go.mod b/go.mod index 2dae8084..37123ee6 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/dromara/carbon/v2 v2.5.2 github.com/eclipse/paho.mqtt.golang v1.5.0 github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df - github.com/go-playground/validator/v10 v10.24.0 + github.com/go-playground/validator/v10 v10.26.0 github.com/gregdel/pushover v1.3.1 github.com/hashicorp/nomad/api v0.0.0-20231213195942-64e3dca9274b // v1.7.2 github.com/jedib0t/go-pretty/v6 v6.6.5 diff --git a/go.sum b/go.sum index 80388253..ad61b162 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg= -github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= +github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= +github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= diff --git a/vendor/github.com/go-playground/validator/v10/.golangci.yaml b/vendor/github.com/go-playground/validator/v10/.golangci.yaml new file mode 100644 index 00000000..eab557ee --- /dev/null +++ b/vendor/github.com/go-playground/validator/v10/.golangci.yaml @@ -0,0 +1,102 @@ +version: "2" +linters: + default: all + disable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - canonicalheader + - containedctx + - contextcheck + - copyloopvar + - cyclop + - decorder + - depguard + - dogsled + - dupl + - dupword + - durationcheck + - err113 + - errcheck + - errchkjson + - errname + - errorlint + - exhaustive + - exhaustruct + - exptostd + - fatcontext + - forbidigo + - forcetypeassert + - funlen + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + - gochecksumtype + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - godox + - goheader + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosmopolitan + - govet + - grouper + - iface + - importas + - inamedparam + - ineffassign + - interfacebloat + - intrange + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - mirror + - misspell + - mnd + - musttag + - nakedret + - nestif + - nilerr + - nilnesserr + - nilnil + - nlreturn + - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - paralleltest + - perfsprint + - prealloc + - predeclared + - promlinter + - protogetter + - reassign + - recvcheck + - revive + - rowserrcheck + - sloglint + - spancheck + - sqlclosecheck + - staticcheck + - tagalign + - tagliatelle + - testableexamples + - testifylint + - testpackage + - thelper + - tparallel + - unparam + - varnamelen + - whitespace + - wrapcheck + - wsl + - zerologlint \ No newline at end of file diff --git a/vendor/github.com/go-playground/validator/v10/Makefile b/vendor/github.com/go-playground/validator/v10/Makefile index e097dfaf..e7caab7f 100644 --- a/vendor/github.com/go-playground/validator/v10/Makefile +++ b/vendor/github.com/go-playground/validator/v10/Makefile @@ -3,7 +3,7 @@ GOCMD=go linters-install: @golangci-lint --version >/dev/null 2>&1 || { \ echo "installing linting tools..."; \ - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v2.0.2; \ } lint: linters-install diff --git a/vendor/github.com/go-playground/validator/v10/README.md b/vendor/github.com/go-playground/validator/v10/README.md index 25eadf02..368b966a 100644 --- a/vendor/github.com/go-playground/validator/v10/README.md +++ b/vendor/github.com/go-playground/validator/v10/README.md @@ -1,8 +1,7 @@ Package validator ================= -[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -![Project status](https://img.shields.io/badge/version-10.24.0-green.svg) -[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator) +![Project status](https://img.shields.io/badge/version-10.25.0-green.svg) +[![Build Status](https://github.com/go-playground/validator/actions/workflows/workflow.yml/badge.svg)](https://github.com/go-playground/validator/actions) [![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator) [![GoDoc](https://godoc.org/github.com/go-playground/validator?status.svg)](https://pkg.go.dev/github.com/go-playground/validator/v10) @@ -173,6 +172,7 @@ validate := validator.New(validator.WithRequiredStructEnabled()) | spicedb | SpiceDb ObjectID/Permission/Type | | datetime | Datetime | | e164 | e164 formatted phone number | +| ein | U.S. Employeer Identification Number | | email | E-mail String | eth_addr | Ethereum Address | | hexadecimal | Hexadecimal String | diff --git a/vendor/github.com/go-playground/validator/v10/baked_in.go b/vendor/github.com/go-playground/validator/v10/baked_in.go index 2f66c183..5332cf3f 100644 --- a/vendor/github.com/go-playground/validator/v10/baked_in.go +++ b/vendor/github.com/go-playground/validator/v10/baked_in.go @@ -9,6 +9,7 @@ import ( "fmt" "io/fs" "net" + "net/mail" "net/url" "os" "reflect" @@ -50,6 +51,7 @@ var ( keysTag: {}, endKeysTag: {}, structOnlyTag: {}, + omitzero: {}, omitempty: {}, omitnil: {}, skipValidationTag: {}, @@ -241,6 +243,7 @@ var ( "mongodb_connection_string": isMongoDBConnectionString, "cron": isCron, "spicedb": isSpiceDB, + "ein": isEIN, } ) @@ -257,7 +260,7 @@ func parseOneOfParam2(s string) []string { oneofValsCacheRWLock.Lock() vals = splitParamsRegex().FindAllString(s, -1) for i := 0; i < len(vals); i++ { - vals[i] = strings.Replace(vals[i], "'", "", -1) + vals[i] = strings.ReplaceAll(vals[i], "'", "") } oneofValsCache[s] = vals oneofValsCacheRWLock.Unlock() @@ -1375,7 +1378,6 @@ func isEqIgnoreCase(fl FieldLevel) bool { param := fl.Param() switch field.Kind() { - case reflect.String: return strings.EqualFold(field.String(), param) } @@ -1417,6 +1419,7 @@ func isPostcodeByIso3166Alpha2Field(fl FieldLevel) bool { panic(fmt.Sprintf("Bad field type %T", currentField.Interface())) } + postcodeRegexInit.Do(initPostcodes) reg, found := postCodeRegexDict[currentField.String()] if !found { return false @@ -1604,7 +1607,6 @@ func isImage(fl FieldLevel) bool { case reflect.String: filePath := field.String() fileInfo, err := os.Stat(filePath) - if err != nil { return false } @@ -1617,7 +1619,9 @@ func isImage(fl FieldLevel) bool { if err != nil { return false } - defer file.Close() + defer func() { + _ = file.Close() + }() mime, err := mimetype.DetectReader(file) if err != nil { @@ -1633,7 +1637,6 @@ func isImage(fl FieldLevel) bool { // isFilePath is the validation function for validating if the current field's value is a valid file path. func isFilePath(fl FieldLevel) bool { - var exists bool var err error @@ -1693,6 +1696,10 @@ func isE164(fl FieldLevel) bool { // isEmail is the validation function for validating if the current field's value is a valid email address. func isEmail(fl FieldLevel) bool { + _, err := mail.ParseAddress(fl.Field().String()) + if err != nil { + return false + } return emailRegex().MatchString(fl.Field().String()) } @@ -1796,6 +1803,20 @@ func hasValue(fl FieldLevel) bool { } } +// hasNotZeroValue is the validation function for validating if the current field's value is not the zero value for its type. +func hasNotZeroValue(fl FieldLevel) bool { + field := fl.Field() + switch field.Kind() { + case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: + return !field.IsNil() + default: + if fl.(*validate).fldIsPointer && field.Interface() != nil { + return !field.IsZero() + } + return field.IsValid() && !field.IsZero() + } +} + // requireCheckFieldKind is a func for check field kind func requireCheckFieldKind(fl FieldLevel, param string, defaultNotFoundValue bool) bool { field := fl.Field() @@ -2211,7 +2232,6 @@ func isGt(fl FieldLevel) bool { case reflect.Struct: if field.Type().ConvertibleTo(timeType) { - return field.Convert(timeType).Interface().(time.Time).After(time.Now().UTC()) } } @@ -2448,7 +2468,6 @@ func isLt(fl FieldLevel) bool { case reflect.Struct: if field.Type().ConvertibleTo(timeType) { - return field.Convert(timeType).Interface().(time.Time).Before(time.Now().UTC()) } } @@ -2628,7 +2647,6 @@ func isDir(fl FieldLevel) bool { // isDirPath is the validation function for validating if the current field's value is a valid directory. func isDirPath(fl FieldLevel) bool { - var exists bool var err error @@ -2941,6 +2959,12 @@ func isCveFormat(fl FieldLevel) bool { // a valid dns RFC 1035 label, defined in RFC 1035. func isDnsRFC1035LabelFormat(fl FieldLevel) bool { val := fl.Field().String() + + size := len(val) + if size > 63 { + return false + } + return dnsRegexRFC1035Label().MatchString(val) } @@ -3044,3 +3068,14 @@ func isCron(fl FieldLevel) bool { cronString := fl.Field().String() return cronRegex().MatchString(cronString) } + +// isEIN is the validation function for validating if the current field's value is a valid U.S. Employer Identification Number (EIN) +func isEIN(fl FieldLevel) bool { + field := fl.Field() + + if field.Len() != 10 { + return false + } + + return einRegex().MatchString(field.String()) +} diff --git a/vendor/github.com/go-playground/validator/v10/cache.go b/vendor/github.com/go-playground/validator/v10/cache.go index 2063e1b7..41d40bfe 100644 --- a/vendor/github.com/go-playground/validator/v10/cache.go +++ b/vendor/github.com/go-playground/validator/v10/cache.go @@ -21,6 +21,7 @@ const ( typeKeys typeEndKeys typeOmitNil + typeOmitZero ) const ( @@ -249,6 +250,10 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s } return + case omitzero: + current.typeof = typeOmitZero + continue + case omitempty: current.typeof = typeOmitEmpty continue @@ -304,7 +309,7 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s } if len(vals) > 1 { - current.param = strings.Replace(strings.Replace(vals[1], utf8HexComma, ",", -1), utf8Pipe, "|", -1) + current.param = strings.ReplaceAll(strings.ReplaceAll(vals[1], utf8HexComma, ","), utf8Pipe, "|") } } current.isBlockEnd = true diff --git a/vendor/github.com/go-playground/validator/v10/doc.go b/vendor/github.com/go-playground/validator/v10/doc.go index c9b1616e..e7a241fb 100644 --- a/vendor/github.com/go-playground/validator/v10/doc.go +++ b/vendor/github.com/go-playground/validator/v10/doc.go @@ -959,7 +959,7 @@ Although an empty string is a valid base64 URL safe value, this will report an empty string as an error, if you wish to accept an empty string as valid you can use this with the omitempty tag. - Usage: base64url + Usage: base64rawurl # Bitcoin Address @@ -1134,6 +1134,12 @@ This validates that a string value contains a valid longitude. Usage: longitude +# Employeer Identification Number EIN + +This validates that a string value contains a valid U.S. Employer Identification Number. + + Usage: ein + # Social Security Number SSN This validates that a string value contains a valid U.S. Social Security Number. diff --git a/vendor/github.com/go-playground/validator/v10/regexes.go b/vendor/github.com/go-playground/validator/v10/regexes.go index 871cf7df..93909b2e 100644 --- a/vendor/github.com/go-playground/validator/v10/regexes.go +++ b/vendor/github.com/go-playground/validator/v10/regexes.go @@ -69,7 +69,7 @@ const ( splitParamsRegexString = `'[^']*'|\S+` bicRegexString = `^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$` semverRegexString = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$` // numbered capture groups https://semver.org/ - dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9]){0,62}$" + dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9])?$" cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html mongodbIdRegexString = "^[a-f\\d]{24}$" mongodbConnStringRegexString = "^mongodb(\\+srv)?:\\/\\/(([a-zA-Z\\d]+):([a-zA-Z\\d$:\\/?#\\[\\]@]+)@)?(([a-z\\d.-]+)(:[\\d]+)?)((,(([a-z\\d.-]+)(:(\\d+))?))*)?(\\/[a-zA-Z-_]{1,64})?(\\?(([a-zA-Z]+)=([a-zA-Z\\d]+))(&(([a-zA-Z\\d]+)=([a-zA-Z\\d]+))?)*)?$" @@ -77,6 +77,7 @@ const ( spicedbIDRegexString = `^(([a-zA-Z0-9/_|\-=+]{1,})|\*)$` spicedbPermissionRegexString = "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$" spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$" + einRegexString = "^(\\d{2}-\\d{7})$" ) func lazyRegexCompile(str string) func() *regexp.Regexp { @@ -160,4 +161,5 @@ var ( spicedbIDRegex = lazyRegexCompile(spicedbIDRegexString) spicedbPermissionRegex = lazyRegexCompile(spicedbPermissionRegexString) spicedbTypeRegex = lazyRegexCompile(spicedbTypeRegexString) + einRegex = lazyRegexCompile(einRegexString) ) diff --git a/vendor/github.com/go-playground/validator/v10/struct_level.go b/vendor/github.com/go-playground/validator/v10/struct_level.go index 271328f7..fa7af9dd 100644 --- a/vendor/github.com/go-playground/validator/v10/struct_level.go +++ b/vendor/github.com/go-playground/validator/v10/struct_level.go @@ -46,9 +46,9 @@ type StructLevel interface { // // NOTES: // - // fieldName and altName get appended to the existing namespace that - // validator is on. e.g. pass 'FirstName' or 'Names[0]' depending - // on the nesting + // fieldName and structFieldName get appended to the existing + // namespace that validator is on. e.g. pass 'FirstName' or + // 'Names[0]' depending on the nesting // // tag can be an existing validation tag or just something you make up // and process on the flip side it's up to you. diff --git a/vendor/github.com/go-playground/validator/v10/validator.go b/vendor/github.com/go-playground/validator/v10/validator.go index 901e7b50..d7c2e658 100644 --- a/vendor/github.com/go-playground/validator/v10/validator.go +++ b/vendor/github.com/go-playground/validator/v10/validator.go @@ -117,6 +117,10 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr return } + if ct.typeof == typeOmitZero { + return + } + if ct.hasTag { if kind == reflect.Invalid { v.str1 = string(append(ns, cf.altName...)) @@ -238,6 +242,19 @@ OUTER: ct = ct.next continue + case typeOmitZero: + v.slflParent = parent + v.flField = current + v.cf = cf + v.ct = ct + + if !hasNotZeroValue(v) { + return + } + + ct = ct.next + continue + case typeOmitNil: v.slflParent = parent v.flField = current diff --git a/vendor/github.com/go-playground/validator/v10/validator_instance.go b/vendor/github.com/go-playground/validator/v10/validator_instance.go index d9f148db..779f689a 100644 --- a/vendor/github.com/go-playground/validator/v10/validator_instance.go +++ b/vendor/github.com/go-playground/validator/v10/validator_instance.go @@ -21,6 +21,7 @@ const ( tagKeySeparator = "=" structOnlyTag = "structonly" noStructLevelTag = "nostructlevel" + omitzero = "omitzero" omitempty = "omitempty" omitnil = "omitnil" isdefault = "isdefault" diff --git a/vendor/modules.txt b/vendor/modules.txt index 9b13bdf6..a9c80647 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -231,7 +231,7 @@ github.com/go-playground/locales/currency # github.com/go-playground/universal-translator v0.18.1 ## explicit; go 1.18 github.com/go-playground/universal-translator -# github.com/go-playground/validator/v10 v10.24.0 +# github.com/go-playground/validator/v10 v10.26.0 ## explicit; go 1.20 github.com/go-playground/validator/v10 # github.com/gogo/protobuf v1.3.2