diff options
| author | 2025-04-14 09:43:56 +0200 | |
|---|---|---|
| committer | 2025-04-14 09:43:56 +0200 | |
| commit | 51b9ef5c346f333e558eca38fd954464322f3b7d (patch) | |
| tree | bf5cd0de887a27c1afc66345b1a464921d96e503 /vendor/github.com/go-playground/validator/v10/baked_in.go | |
| parent | [docs] Remind the user that password resets don't work without restarting. (#... (diff) | |
| download | gotosocial-51b9ef5c346f333e558eca38fd954464322f3b7d.tar.xz | |
[chore]: Bump github.com/gin-contrib/gzip from 1.2.2 to 1.2.3 (#4000)
Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/gin-contrib/gzip/releases)
- [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/gzip/compare/v1.2.2...v1.2.3)
---
updated-dependencies:
- dependency-name: github.com/gin-contrib/gzip
dependency-version: 1.2.3
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/go-playground/validator/v10/baked_in.go')
| -rw-r--r-- | vendor/github.com/go-playground/validator/v10/baked_in.go | 51 |
1 files changed, 43 insertions, 8 deletions
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 2f66c1836..5332cf3fa 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()) +} |
