diff options
author | 2023-05-22 09:17:48 +0200 | |
---|---|---|
committer | 2023-05-22 09:17:48 +0200 | |
commit | ea1bbacf4b51628f55bc831f511ce60ddb72d71c (patch) | |
tree | f90266529625a01090a45500b8a017722047a5dd /vendor/github.com/go-playground | |
parent | [chore] Replace pinafore with semaphore (#1801) (diff) | |
download | gotosocial-ea1bbacf4b51628f55bc831f511ce60ddb72d71c.tar.xz |
[chore]: Bump github.com/go-playground/validator/v10 (#1812)
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.13.0 to 10.14.0.
- [Release notes](https://github.com/go-playground/validator/releases)
- [Commits](https://github.com/go-playground/validator/compare/v10.13.0...v10.14.0)
---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
dependency-type: direct:production
update-type: version-update:semver-minor
...
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')
5 files changed, 79 insertions, 15 deletions
diff --git a/vendor/github.com/go-playground/validator/v10/.gitignore b/vendor/github.com/go-playground/validator/v10/.gitignore index 2410a91b9..6305e5290 100644 --- a/vendor/github.com/go-playground/validator/v10/.gitignore +++ b/vendor/github.com/go-playground/validator/v10/.gitignore @@ -26,6 +26,7 @@ _testmain.go *.test *.out *.txt +/**/*.DS_Store cover.html README.html .idea diff --git a/vendor/github.com/go-playground/validator/v10/README.md b/vendor/github.com/go-playground/validator/v10/README.md index f5a9b75bb..931b3414a 100644 --- a/vendor/github.com/go-playground/validator/v10/README.md +++ b/vendor/github.com/go-playground/validator/v10/README.md @@ -1,7 +1,7 @@ Package validator ================= <img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v10/logo.png">[](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - + [](https://travis-ci.org/go-playground/validator) [](https://coveralls.io/github/go-playground/validator?branch=master) [](https://goreportcard.com/report/github.com/go-playground/validator) @@ -228,6 +228,7 @@ Baked-in Validations | dirpath | Directory Path | | file | Existing File | | filepath | File Path | +| image | Image | | isdefault | Is Default | | len | Length | | max | Maximum | 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 d66980b6e..8e6b169cb 100644 --- a/vendor/github.com/go-playground/validator/v10/baked_in.go +++ b/vendor/github.com/go-playground/validator/v10/baked_in.go @@ -22,6 +22,7 @@ import ( "golang.org/x/crypto/sha3" "golang.org/x/text/language" + "github.com/gabriel-vasile/mimetype" "github.com/leodido/go-urn" ) @@ -144,6 +145,7 @@ var ( "endswith": endsWith, "startsnotwith": startsNotWith, "endsnotwith": endsNotWith, + "image": isImage, "isbn": isISBN, "isbn10": isISBN10, "isbn13": isISBN13, @@ -1488,6 +1490,67 @@ func isFile(fl FieldLevel) bool { panic(fmt.Sprintf("Bad field type %T", field.Interface())) } +// isImage is the validation function for validating if the current field's value contains the path to a valid image file +func isImage(fl FieldLevel) bool { + mimetypes := map[string]bool{ + "image/bmp": true, + "image/cis-cod": true, + "image/gif": true, + "image/ief": true, + "image/jpeg": true, + "image/jp2": true, + "image/jpx": true, + "image/jpm": true, + "image/pipeg": true, + "image/png": true, + "image/svg+xml": true, + "image/tiff": true, + "image/webp": true, + "image/x-cmu-raster": true, + "image/x-cmx": true, + "image/x-icon": true, + "image/x-portable-anymap": true, + "image/x-portable-bitmap": true, + "image/x-portable-graymap": true, + "image/x-portable-pixmap": true, + "image/x-rgb": true, + "image/x-xbitmap": true, + "image/x-xpixmap": true, + "image/x-xwindowdump": true, + } + field := fl.Field() + + switch field.Kind() { + case reflect.String: + filePath := field.String() + fileInfo, err := os.Stat(filePath) + + if err != nil { + return false + } + + if fileInfo.IsDir() { + return false + } + + file, err := os.Open(filePath) + if err != nil { + return false + } + defer file.Close() + + mime, err := mimetype.DetectReader(file) + if err != nil { + return false + } + + if _, ok := mimetypes[mime.String()]; ok { + return true + } + } + return false +} + // isFilePath is the validation function for validating if the current field's value is a valid file path. func isFilePath(fl FieldLevel) bool { diff --git a/vendor/github.com/go-playground/validator/v10/country_codes.go b/vendor/github.com/go-playground/validator/v10/country_codes.go index 91b2e0b90..0119f0574 100644 --- a/vendor/github.com/go-playground/validator/v10/country_codes.go +++ b/vendor/github.com/go-playground/validator/v10/country_codes.go @@ -1135,7 +1135,7 @@ var iso3166_2 = map[string]bool{ "VN-69": true, "VN-70": true, "VN-71": true, "VN-72": true, "VN-73": true, "VN-CT": true, "VN-DN": true, "VN-HN": true, "VN-HP": true, "VN-SG": true, "VU-MAP": true, "VU-PAM": true, "VU-SAM": true, "VU-SEE": true, "VU-TAE": true, - "VU-TOB": true, "WF-SG": true,"WF-UV": true, "WS-AA": true, "WS-AL": true, "WS-AT": true, "WS-FA": true, + "VU-TOB": true, "WF-SG": true, "WF-UV": true, "WS-AA": true, "WS-AL": true, "WS-AT": true, "WS-FA": true, "WS-GE": true, "WS-GI": true, "WS-PA": true, "WS-SA": true, "WS-TU": true, "WS-VF": true, "WS-VS": true, "YE-AB": true, "YE-AD": true, "YE-AM": true, "YE-BA": true, "YE-DA": true, "YE-DH": true, "YE-HD": true, "YE-HJ": true, "YE-HU": true, diff --git a/vendor/github.com/go-playground/validator/v10/doc.go b/vendor/github.com/go-playground/validator/v10/doc.go index f31a7d538..f5aa9e523 100644 --- a/vendor/github.com/go-playground/validator/v10/doc.go +++ b/vendor/github.com/go-playground/validator/v10/doc.go @@ -863,7 +863,6 @@ This validates that a string value is a valid JWT Usage: jwt - # File This validates that a string value contains a valid file path and that @@ -872,6 +871,15 @@ This is done using os.Stat, which is a platform independent function. Usage: file +# Image path + +This validates that a string value contains a valid file path and that +the file exists on the machine and is an image. +This is done using os.Stat and github.com/gabriel-vasile/mimetype + + Usage: image + +# URL String # File Path @@ -881,7 +889,6 @@ This is done using os.Stat, which is a platform independent function. Usage: filepath - # URL String This validates that a string value contains a valid url @@ -923,7 +930,6 @@ you can use this with the omitempty tag. Usage: base64url - # Base64RawURL String This validates that a string value contains a valid base64 URL safe value, @@ -934,7 +940,6 @@ you can use this with the omitempty tag. Usage: base64url - # Bitcoin Address This validates that a string value contains a valid bitcoin address. @@ -1267,7 +1272,6 @@ This is done using os.Stat, which is a platform independent function. Usage: dir - # Directory Path This validates that a string value contains a valid directory but does @@ -1278,7 +1282,6 @@ may not exist at the time of validation. Usage: dirpath - # HostPort This validates that a string value contains a valid DNS hostname and port that @@ -1350,7 +1353,6 @@ More information on https://semver.org/ Usage: semver - # CVE Identifier This validates that a string value is a valid cve id, defined in cve mitre. @@ -1358,17 +1360,15 @@ More information on https://cve.mitre.org/ Usage: cve - # Credit Card This validates that a string value contains a valid credit card number using Luhn algorithm. Usage: credit_card - # Luhn Checksum - Usage: luhn_checksum + Usage: luhn_checksum This validates that a string or (u)int value contains a valid checksum using the Luhn algorithm. @@ -1376,8 +1376,7 @@ This validates that a string or (u)int value contains a valid checksum using the This validates that a string is a valid 24 character hexadecimal string. - Usage: mongodb - + Usage: mongodb # Cron @@ -1385,7 +1384,7 @@ This validates that a string value contains a valid cron expression. Usage: cron -Alias Validators and Tags +# Alias Validators and Tags Alias Validators and Tags NOTE: When returning an error, the tag returned in "FieldError" will be |