mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 10:02:26 -05:00 
			
		
		
		
	[chore]: Bump github.com/gin-contrib/cors from 1.4.0 to 1.5.0 (#2388)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
					parent
					
						
							
								e4e0a5e3f6
							
						
					
				
			
			
				commit
				
					
						66b77acb1c
					
				
			
		
					 169 changed files with 173005 additions and 56262 deletions
				
			
		
							
								
								
									
										2
									
								
								vendor/github.com/go-playground/validator/v10/Makefile
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/go-playground/validator/v10/Makefile
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -13,6 +13,6 @@ test: | |||
| 	$(GOCMD) test -cover -race ./... | ||||
| 
 | ||||
| bench: | ||||
| 	$(GOCMD) test -bench=. -benchmem ./... | ||||
| 	$(GOCMD) test -run=NONE -bench=. -benchmem ./... | ||||
| 
 | ||||
| .PHONY: test lint linters-install | ||||
							
								
								
									
										140
									
								
								vendor/github.com/go-playground/validator/v10/README.md
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										140
									
								
								vendor/github.com/go-playground/validator/v10/README.md
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -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) | ||||
|  | ||||
| <img align="right" src="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) | ||||
|  | @ -67,6 +67,12 @@ Please see https://pkg.go.dev/github.com/go-playground/validator/v10 for detaile | |||
| Baked-in Validations | ||||
| ------ | ||||
| 
 | ||||
| ### Special Notes: | ||||
| - If new to using validator it is highly recommended to initialize it using the `WithRequiredStructEnabled` option which is opt-in to new behaviour that will become the default behaviour in v11+. See documentation for more details. | ||||
| ```go | ||||
| validate := validator.New(validator.WithRequiredStructEnabled()) | ||||
| ``` | ||||
| 
 | ||||
| ### Fields: | ||||
| 
 | ||||
| | Tag | Description | | ||||
|  | @ -158,6 +164,7 @@ Baked-in Validations | |||
| | credit_card | Credit Card Number | | ||||
| | mongodb | MongoDB ObjectID | | ||||
| | cron | Cron | | ||||
| | spicedb | SpiceDb ObjectID/Permission/Type | | ||||
| | datetime | Datetime | | ||||
| | e164 | e164 formatted phone number | | ||||
| | email | E-mail String | ||||
|  | @ -259,71 +266,72 @@ Benchmarks | |||
| ------ | ||||
| ###### Run on MacBook Pro (15-inch, 2017) go version go1.10.2 darwin/amd64 | ||||
| ```go | ||||
| go version go1.21.0 darwin/arm64 | ||||
| goos: darwin | ||||
| goarch: amd64 | ||||
| pkg: github.com/go-playground/validator | ||||
| BenchmarkFieldSuccess-8                                         20000000                83.6 ns/op             0 B/op          0 allocs/op | ||||
| BenchmarkFieldSuccessParallel-8                                 50000000                26.8 ns/op             0 B/op          0 allocs/op | ||||
| BenchmarkFieldFailure-8                                          5000000               291 ns/op             208 B/op          4 allocs/op | ||||
| BenchmarkFieldFailureParallel-8                                 20000000               107 ns/op             208 B/op          4 allocs/op | ||||
| BenchmarkFieldArrayDiveSuccess-8                                 2000000               623 ns/op             201 B/op         11 allocs/op | ||||
| BenchmarkFieldArrayDiveSuccessParallel-8                        10000000               237 ns/op             201 B/op         11 allocs/op | ||||
| BenchmarkFieldArrayDiveFailure-8                                 2000000               859 ns/op             412 B/op         16 allocs/op | ||||
| BenchmarkFieldArrayDiveFailureParallel-8                         5000000               335 ns/op             413 B/op         16 allocs/op | ||||
| BenchmarkFieldMapDiveSuccess-8                                   1000000              1292 ns/op             432 B/op         18 allocs/op | ||||
| BenchmarkFieldMapDiveSuccessParallel-8                           3000000               467 ns/op             432 B/op         18 allocs/op | ||||
| BenchmarkFieldMapDiveFailure-8                                   1000000              1082 ns/op             512 B/op         16 allocs/op | ||||
| BenchmarkFieldMapDiveFailureParallel-8                           5000000               425 ns/op             512 B/op         16 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysSuccess-8                           1000000              1539 ns/op             480 B/op         21 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysSuccessParallel-8                   3000000               613 ns/op             480 B/op         21 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysFailure-8                           1000000              1413 ns/op             721 B/op         21 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysFailureParallel-8                   3000000               575 ns/op             721 B/op         21 allocs/op | ||||
| BenchmarkFieldCustomTypeSuccess-8                               10000000               216 ns/op              32 B/op          2 allocs/op | ||||
| BenchmarkFieldCustomTypeSuccessParallel-8                       20000000                82.2 ns/op            32 B/op          2 allocs/op | ||||
| BenchmarkFieldCustomTypeFailure-8                                5000000               274 ns/op             208 B/op          4 allocs/op | ||||
| BenchmarkFieldCustomTypeFailureParallel-8                       20000000               116 ns/op             208 B/op          4 allocs/op | ||||
| BenchmarkFieldOrTagSuccess-8                                     2000000               740 ns/op              16 B/op          1 allocs/op | ||||
| BenchmarkFieldOrTagSuccessParallel-8                             3000000               474 ns/op              16 B/op          1 allocs/op | ||||
| BenchmarkFieldOrTagFailure-8                                     3000000               471 ns/op             224 B/op          5 allocs/op | ||||
| BenchmarkFieldOrTagFailureParallel-8                             3000000               414 ns/op             224 B/op          5 allocs/op | ||||
| BenchmarkStructLevelValidationSuccess-8                         10000000               213 ns/op              32 B/op          2 allocs/op | ||||
| BenchmarkStructLevelValidationSuccessParallel-8                 20000000                91.8 ns/op            32 B/op          2 allocs/op | ||||
| BenchmarkStructLevelValidationFailure-8                          3000000               473 ns/op             304 B/op          8 allocs/op | ||||
| BenchmarkStructLevelValidationFailureParallel-8                 10000000               234 ns/op             304 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeSuccess-8                         5000000               385 ns/op              32 B/op          2 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeSuccessParallel-8                10000000               161 ns/op              32 B/op          2 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeFailure-8                         2000000               640 ns/op             424 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeFailureParallel-8                 5000000               318 ns/op             440 B/op         10 allocs/op | ||||
| BenchmarkStructFilteredSuccess-8                                 2000000               597 ns/op             288 B/op          9 allocs/op | ||||
| BenchmarkStructFilteredSuccessParallel-8                        10000000               266 ns/op             288 B/op          9 allocs/op | ||||
| BenchmarkStructFilteredFailure-8                                 3000000               454 ns/op             256 B/op          7 allocs/op | ||||
| BenchmarkStructFilteredFailureParallel-8                        10000000               214 ns/op             256 B/op          7 allocs/op | ||||
| BenchmarkStructPartialSuccess-8                                  3000000               502 ns/op             256 B/op          6 allocs/op | ||||
| BenchmarkStructPartialSuccessParallel-8                         10000000               225 ns/op             256 B/op          6 allocs/op | ||||
| BenchmarkStructPartialFailure-8                                  2000000               702 ns/op             480 B/op         11 allocs/op | ||||
| BenchmarkStructPartialFailureParallel-8                          5000000               329 ns/op             480 B/op         11 allocs/op | ||||
| BenchmarkStructExceptSuccess-8                                   2000000               793 ns/op             496 B/op         12 allocs/op | ||||
| BenchmarkStructExceptSuccessParallel-8                          10000000               193 ns/op             240 B/op          5 allocs/op | ||||
| BenchmarkStructExceptFailure-8                                   2000000               639 ns/op             464 B/op         10 allocs/op | ||||
| BenchmarkStructExceptFailureParallel-8                           5000000               300 ns/op             464 B/op         10 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldSuccess-8                         3000000               417 ns/op              72 B/op          3 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldSuccessParallel-8                10000000               163 ns/op              72 B/op          3 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldFailure-8                         2000000               645 ns/op             304 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldFailureParallel-8                 5000000               285 ns/op             304 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldSuccess-8              3000000               588 ns/op              80 B/op          4 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel-8     10000000               221 ns/op              80 B/op          4 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldFailure-8              2000000               868 ns/op             320 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldFailureParallel-8      5000000               337 ns/op             320 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleSuccess-8                                   5000000               260 ns/op               0 B/op          0 allocs/op | ||||
| BenchmarkStructSimpleSuccessParallel-8                          20000000                90.6 ns/op             0 B/op          0 allocs/op | ||||
| BenchmarkStructSimpleFailure-8                                   2000000               619 ns/op             424 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleFailureParallel-8                           5000000               296 ns/op             424 B/op          9 allocs/op | ||||
| BenchmarkStructComplexSuccess-8                                  1000000              1454 ns/op             128 B/op          8 allocs/op | ||||
| BenchmarkStructComplexSuccessParallel-8                          3000000               579 ns/op             128 B/op          8 allocs/op | ||||
| BenchmarkStructComplexFailure-8                                   300000              4140 ns/op            3041 B/op         53 allocs/op | ||||
| BenchmarkStructComplexFailureParallel-8                          1000000              2127 ns/op            3041 B/op         53 allocs/op | ||||
| BenchmarkOneof-8                                                10000000               140 ns/op               0 B/op          0 allocs/op | ||||
| BenchmarkOneofParallel-8                                        20000000                70.1 ns/op             0 B/op          0 allocs/op | ||||
| goarch: arm64 | ||||
| pkg: github.com/go-playground/validator/v10 | ||||
| BenchmarkFieldSuccess-8                                         33142266                35.94 ns/op            0 B/op          0 allocs/op | ||||
| BenchmarkFieldSuccessParallel-8                                 200816191                6.568 ns/op           0 B/op          0 allocs/op | ||||
| BenchmarkFieldFailure-8                                          6779707               175.1 ns/op           200 B/op          4 allocs/op | ||||
| BenchmarkFieldFailureParallel-8                                 11044147               108.4 ns/op           200 B/op          4 allocs/op | ||||
| BenchmarkFieldArrayDiveSuccess-8                                 6054232               194.4 ns/op            97 B/op          5 allocs/op | ||||
| BenchmarkFieldArrayDiveSuccessParallel-8                        12523388                94.07 ns/op           97 B/op          5 allocs/op | ||||
| BenchmarkFieldArrayDiveFailure-8                                 3587043               334.3 ns/op           300 B/op         10 allocs/op | ||||
| BenchmarkFieldArrayDiveFailureParallel-8                         5816665               200.8 ns/op           300 B/op         10 allocs/op | ||||
| BenchmarkFieldMapDiveSuccess-8                                   2217910               540.1 ns/op           288 B/op         14 allocs/op | ||||
| BenchmarkFieldMapDiveSuccessParallel-8                           4446698               258.7 ns/op           288 B/op         14 allocs/op | ||||
| BenchmarkFieldMapDiveFailure-8                                   2392759               504.6 ns/op           376 B/op         13 allocs/op | ||||
| BenchmarkFieldMapDiveFailureParallel-8                           4244199               286.9 ns/op           376 B/op         13 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysSuccess-8                           2005857               592.1 ns/op           288 B/op         14 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysSuccessParallel-8                   4400850               296.9 ns/op           288 B/op         14 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysFailure-8                           1850227               643.8 ns/op           553 B/op         16 allocs/op | ||||
| BenchmarkFieldMapDiveWithKeysFailureParallel-8                   3293233               375.1 ns/op           553 B/op         16 allocs/op | ||||
| BenchmarkFieldCustomTypeSuccess-8                               12174412                98.25 ns/op           32 B/op          2 allocs/op | ||||
| BenchmarkFieldCustomTypeSuccessParallel-8                       34389907                35.49 ns/op           32 B/op          2 allocs/op | ||||
| BenchmarkFieldCustomTypeFailure-8                                7582524               156.6 ns/op           184 B/op          3 allocs/op | ||||
| BenchmarkFieldCustomTypeFailureParallel-8                       13019902                92.79 ns/op          184 B/op          3 allocs/op | ||||
| BenchmarkFieldOrTagSuccess-8                                     3427260               349.4 ns/op            16 B/op          1 allocs/op | ||||
| BenchmarkFieldOrTagSuccessParallel-8                            15144128                81.25 ns/op           16 B/op          1 allocs/op | ||||
| BenchmarkFieldOrTagFailure-8                                     5913546               201.9 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkFieldOrTagFailureParallel-8                             9810212               113.7 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkStructLevelValidationSuccess-8                         13456327                87.66 ns/op           16 B/op          1 allocs/op | ||||
| BenchmarkStructLevelValidationSuccessParallel-8                 41818888                27.77 ns/op           16 B/op          1 allocs/op | ||||
| BenchmarkStructLevelValidationFailure-8                          4166284               272.6 ns/op           264 B/op          7 allocs/op | ||||
| BenchmarkStructLevelValidationFailureParallel-8                  7594581               152.1 ns/op           264 B/op          7 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeSuccess-8                         6508082               182.6 ns/op            32 B/op          2 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeSuccessParallel-8                23078605                54.78 ns/op           32 B/op          2 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeFailure-8                         3118352               381.0 ns/op           416 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleCustomTypeFailureParallel-8                 5300738               224.1 ns/op           432 B/op         10 allocs/op | ||||
| BenchmarkStructFilteredSuccess-8                                 4761807               251.1 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkStructFilteredSuccessParallel-8                         8792598               128.6 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkStructFilteredFailure-8                                 5202573               232.1 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkStructFilteredFailureParallel-8                         9591267               121.4 ns/op           216 B/op          5 allocs/op | ||||
| BenchmarkStructPartialSuccess-8                                  5188512               231.6 ns/op           224 B/op          4 allocs/op | ||||
| BenchmarkStructPartialSuccessParallel-8                          9179776               123.1 ns/op           224 B/op          4 allocs/op | ||||
| BenchmarkStructPartialFailure-8                                  3071212               392.5 ns/op           440 B/op          9 allocs/op | ||||
| BenchmarkStructPartialFailureParallel-8                          5344261               223.7 ns/op           440 B/op          9 allocs/op | ||||
| BenchmarkStructExceptSuccess-8                                   3184230               375.0 ns/op           424 B/op          8 allocs/op | ||||
| BenchmarkStructExceptSuccessParallel-8                          10090130               108.9 ns/op           208 B/op          3 allocs/op | ||||
| BenchmarkStructExceptFailure-8                                   3347226               357.7 ns/op           424 B/op          8 allocs/op | ||||
| BenchmarkStructExceptFailureParallel-8                           5654923               209.5 ns/op           424 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldSuccess-8                         5232265               229.1 ns/op            56 B/op          3 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldSuccessParallel-8                17436674                64.75 ns/op           56 B/op          3 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldFailure-8                         3128613               383.6 ns/op           272 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCrossFieldFailureParallel-8                 6994113               168.8 ns/op           272 B/op          8 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldSuccess-8              3506487               340.9 ns/op            64 B/op          4 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel-8     13431300                91.77 ns/op           64 B/op          4 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldFailure-8              2410566               500.9 ns/op           288 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleCrossStructCrossFieldFailureParallel-8      6344510               188.2 ns/op           288 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleSuccess-8                                   8922726               133.8 ns/op             0 B/op          0 allocs/op | ||||
| BenchmarkStructSimpleSuccessParallel-8                          55291153                23.63 ns/op            0 B/op          0 allocs/op | ||||
| BenchmarkStructSimpleFailure-8                                   3171553               378.4 ns/op           416 B/op          9 allocs/op | ||||
| BenchmarkStructSimpleFailureParallel-8                           5571692               212.0 ns/op           416 B/op          9 allocs/op | ||||
| BenchmarkStructComplexSuccess-8                                  1683750               714.5 ns/op           224 B/op          5 allocs/op | ||||
| BenchmarkStructComplexSuccessParallel-8                          4578046               257.0 ns/op           224 B/op          5 allocs/op | ||||
| BenchmarkStructComplexFailure-8                                   481585              2547 ns/op            3041 B/op         48 allocs/op | ||||
| BenchmarkStructComplexFailureParallel-8                           965764              1577 ns/op            3040 B/op         48 allocs/op | ||||
| BenchmarkOneof-8                                                17380881                68.50 ns/op            0 B/op          0 allocs/op | ||||
| BenchmarkOneofParallel-8                                         8084733               153.5 ns/op             0 B/op          0 allocs/op | ||||
| ``` | ||||
| 
 | ||||
| Complementary Software | ||||
|  |  | |||
							
								
								
									
										94
									
								
								vendor/github.com/go-playground/validator/v10/baked_in.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										94
									
								
								vendor/github.com/go-playground/validator/v10/baked_in.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -23,7 +23,7 @@ import ( | |||
| 	"golang.org/x/text/language" | ||||
| 
 | ||||
| 	"github.com/gabriel-vasile/mimetype" | ||||
| 	"github.com/leodido/go-urn" | ||||
| 	urn "github.com/leodido/go-urn" | ||||
| ) | ||||
| 
 | ||||
| // Func accepts a FieldLevel interface for all validation needs. The return | ||||
|  | @ -230,6 +230,7 @@ var ( | |||
| 		"luhn_checksum":                 hasLuhnChecksum, | ||||
| 		"mongodb":                       isMongoDB, | ||||
| 		"cron":                          isCron, | ||||
| 		"spicedb":                       isSpiceDB, | ||||
| 	} | ||||
| ) | ||||
| 
 | ||||
|  | @ -372,9 +373,9 @@ func isMAC(fl FieldLevel) bool { | |||
| 
 | ||||
| // isCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address. | ||||
| func isCIDRv4(fl FieldLevel) bool { | ||||
| 	ip, _, err := net.ParseCIDR(fl.Field().String()) | ||||
| 	ip, net, err := net.ParseCIDR(fl.Field().String()) | ||||
| 
 | ||||
| 	return err == nil && ip.To4() != nil | ||||
| 	return err == nil && ip.To4() != nil && net.IP.Equal(ip) | ||||
| } | ||||
| 
 | ||||
| // isCIDRv6 is the validation function for validating if the field's value is a valid v6 CIDR address. | ||||
|  | @ -1294,8 +1295,13 @@ func isEq(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() == p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() == p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() == p | ||||
| 
 | ||||
|  | @ -1561,6 +1567,10 @@ func isFilePath(fl FieldLevel) bool { | |||
| 
 | ||||
| 	field := fl.Field() | ||||
| 
 | ||||
| 	// Not valid if it is a directory. | ||||
| 	if isDir(fl) { | ||||
| 		return false | ||||
| 	} | ||||
| 	// If it exists, it obviously is valid. | ||||
| 	// This is done first to avoid code duplication and unnecessary additional logic. | ||||
| 	if exists = isFile(fl); exists { | ||||
|  | @ -1710,7 +1720,7 @@ func hasValue(fl FieldLevel) bool { | |||
| 		if fl.(*validate).fldIsPointer && field.Interface() != nil { | ||||
| 			return true | ||||
| 		} | ||||
| 		return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface() | ||||
| 		return field.IsValid() && !field.IsZero() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -1734,7 +1744,7 @@ func requireCheckFieldKind(fl FieldLevel, param string, defaultNotFoundValue boo | |||
| 		if nullable && field.Interface() != nil { | ||||
| 			return false | ||||
| 		} | ||||
| 		return field.IsValid() && field.Interface() == reflect.Zero(field.Type()).Interface() | ||||
| 		return field.IsValid() && field.IsZero() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -1755,8 +1765,11 @@ func requireCheckFieldValue( | |||
| 	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: | ||||
| 		return field.Uint() == asUint(value) | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		return field.Float() == asFloat(value) | ||||
| 	case reflect.Float32: | ||||
| 		return field.Float() == asFloat32(value) | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		return field.Float() == asFloat64(value) | ||||
| 
 | ||||
| 	case reflect.Slice, reflect.Map, reflect.Array: | ||||
| 		return int64(field.Len()) == asInt(value) | ||||
|  | @ -2055,8 +2068,13 @@ func isGte(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() >= p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() >= p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() >= p | ||||
| 
 | ||||
|  | @ -2101,10 +2119,16 @@ func isGt(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() > p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() > p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() > p | ||||
| 
 | ||||
| 	case reflect.Struct: | ||||
| 
 | ||||
| 		if field.Type().ConvertibleTo(timeType) { | ||||
|  | @ -2143,8 +2167,13 @@ func hasLengthOf(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() == p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() == p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() == p | ||||
| 	} | ||||
|  | @ -2276,8 +2305,13 @@ func isLte(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() <= p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() <= p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() <= p | ||||
| 
 | ||||
|  | @ -2322,8 +2356,13 @@ func isLt(fl FieldLevel) bool { | |||
| 
 | ||||
| 		return field.Uint() < p | ||||
| 
 | ||||
| 	case reflect.Float32, reflect.Float64: | ||||
| 		p := asFloat(param) | ||||
| 	case reflect.Float32: | ||||
| 		p := asFloat32(param) | ||||
| 
 | ||||
| 		return field.Float() < p | ||||
| 
 | ||||
| 	case reflect.Float64: | ||||
| 		p := asFloat64(param) | ||||
| 
 | ||||
| 		return field.Float() < p | ||||
| 
 | ||||
|  | @ -2808,6 +2847,23 @@ func isMongoDB(fl FieldLevel) bool { | |||
| 	return mongodbRegex.MatchString(val) | ||||
| } | ||||
| 
 | ||||
| // isSpiceDB is the validation function for validating if the current field's value is valid for use with Authzed SpiceDB in the indicated way | ||||
| func isSpiceDB(fl FieldLevel) bool { | ||||
| 	val := fl.Field().String() | ||||
| 	param := fl.Param() | ||||
| 
 | ||||
| 	switch param { | ||||
| 	case "permission": | ||||
| 		return spicedbPermissionRegex.MatchString(val) | ||||
| 	case "type": | ||||
| 		return spicedbTypeRegex.MatchString(val) | ||||
| 	case "id", "": | ||||
| 		return spicedbIDRegex.MatchString(val) | ||||
| 	} | ||||
| 
 | ||||
| 	panic("Unrecognized parameter: " + param) | ||||
| } | ||||
| 
 | ||||
| // isCreditCard is the validation function for validating if the current field's value is a valid credit card number | ||||
| func isCreditCard(fl FieldLevel) bool { | ||||
| 	val := fl.Field().String() | ||||
|  |  | |||
							
								
								
									
										26
									
								
								vendor/github.com/go-playground/validator/v10/doc.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/go-playground/validator/v10/doc.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -247,7 +247,7 @@ Example #2 | |||
| This validates that the value is not the data types default zero value. | ||||
| For numbers ensures value is not zero. For strings ensures value is | ||||
| not "". For slices, maps, pointers, interfaces, channels and functions | ||||
| ensures the value is not nil. | ||||
| ensures the value is not nil. For structs ensures value is not the zero value when using WithRequiredStructEnabled. | ||||
| 
 | ||||
| 	Usage: required | ||||
| 
 | ||||
|  | @ -256,7 +256,7 @@ ensures the value is not nil. | |||
| The field under validation must be present and not empty only if all | ||||
| the other specified fields are equal to the value following the specified | ||||
| field. For strings ensures value is not "". For slices, maps, pointers, | ||||
| interfaces, channels and functions ensures the value is not nil. | ||||
| interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_if | ||||
| 
 | ||||
|  | @ -273,7 +273,7 @@ Examples: | |||
| The field under validation must be present and not empty unless all | ||||
| the other specified fields are equal to the value following the specified | ||||
| field. For strings ensures value is not "". For slices, maps, pointers, | ||||
| interfaces, channels and functions ensures the value is not nil. | ||||
| interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_unless | ||||
| 
 | ||||
|  | @ -290,7 +290,7 @@ Examples: | |||
| The field under validation must be present and not empty only if any | ||||
| of the other specified fields are present. For strings ensures value is | ||||
| not "". For slices, maps, pointers, interfaces, channels and functions | ||||
| ensures the value is not nil. | ||||
| ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_with | ||||
| 
 | ||||
|  | @ -307,7 +307,7 @@ Examples: | |||
| The field under validation must be present and not empty only if all | ||||
| of the other specified fields are present. For strings ensures value is | ||||
| not "". For slices, maps, pointers, interfaces, channels and functions | ||||
| ensures the value is not nil. | ||||
| ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_with_all | ||||
| 
 | ||||
|  | @ -321,7 +321,7 @@ Example: | |||
| The field under validation must be present and not empty only when any | ||||
| of the other specified fields are not present. For strings ensures value is | ||||
| not "". For slices, maps, pointers, interfaces, channels and functions | ||||
| ensures the value is not nil. | ||||
| ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_without | ||||
| 
 | ||||
|  | @ -338,7 +338,7 @@ Examples: | |||
| The field under validation must be present and not empty only when all | ||||
| of the other specified fields are not present. For strings ensures value is | ||||
| not "". For slices, maps, pointers, interfaces, channels and functions | ||||
| ensures the value is not nil. | ||||
| ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: required_without_all | ||||
| 
 | ||||
|  | @ -352,7 +352,7 @@ Example: | |||
| The field under validation must not be present or not empty only if all | ||||
| the other specified fields are equal to the value following the specified | ||||
| field. For strings ensures value is not "". For slices, maps, pointers, | ||||
| interfaces, channels and functions ensures the value is not nil. | ||||
| interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: excluded_if | ||||
| 
 | ||||
|  | @ -369,7 +369,7 @@ Examples: | |||
| The field under validation must not be present or empty unless all | ||||
| the other specified fields are equal to the value following the specified | ||||
| field. For strings ensures value is not "". For slices, maps, pointers, | ||||
| interfaces, channels and functions ensures the value is not nil. | ||||
| interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value. | ||||
| 
 | ||||
| 	Usage: excluded_unless | ||||
| 
 | ||||
|  | @ -879,8 +879,6 @@ This is done using os.Stat and github.com/gabriel-vasile/mimetype | |||
| 
 | ||||
| 	Usage: image | ||||
| 
 | ||||
| # URL String | ||||
| 
 | ||||
| # File Path | ||||
| 
 | ||||
| This validates that a string value contains a valid file path but does not | ||||
|  | @ -1384,6 +1382,12 @@ This validates that a string value contains a valid cron expression. | |||
| 
 | ||||
| 	Usage: cron | ||||
| 
 | ||||
| # SpiceDb ObjectID/Permission/Object Type | ||||
| 
 | ||||
| This validates that a string is valid for use with SpiceDb for the indicated purpose. If no purpose is given, a purpose of 'id' is assumed. | ||||
| 
 | ||||
| 	Usage: spicedb=id|permission|type | ||||
| 
 | ||||
| # Alias Validators and Tags | ||||
| 
 | ||||
| Alias Validators and Tags | ||||
|  |  | |||
							
								
								
									
										16
									
								
								vendor/github.com/go-playground/validator/v10/options.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								vendor/github.com/go-playground/validator/v10/options.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| package validator | ||||
| 
 | ||||
| // Option represents a configurations option to be applied to validator during initialization. | ||||
| type Option func(*Validate) | ||||
| 
 | ||||
| // WithRequiredStructEnabled enables required tag on non-pointer structs to be applied instead of ignored. | ||||
| // | ||||
| // This was made opt-in behaviour in order to maintain backward compatibility with the behaviour previous | ||||
| // to being able to apply struct level validations on struct fields directly. | ||||
| // | ||||
| // It is recommended you enabled this as it will be the default behaviour in v11+ | ||||
| func WithRequiredStructEnabled() Option { | ||||
| 	return func(v *Validate) { | ||||
| 		v.requiredStructEnabled = true | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										6
									
								
								vendor/github.com/go-playground/validator/v10/regexes.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/go-playground/validator/v10/regexes.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -68,6 +68,9 @@ const ( | |||
| 	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 | ||||
| 	mongodbRegexString               = "^[a-f\\d]{24}$" | ||||
| 	cronRegexString                  = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})` | ||||
| 	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]$" | ||||
| ) | ||||
| 
 | ||||
| var ( | ||||
|  | @ -134,4 +137,7 @@ var ( | |||
| 	cveRegex                   = regexp.MustCompile(cveRegexString) | ||||
| 	mongodbRegex               = regexp.MustCompile(mongodbRegexString) | ||||
| 	cronRegex                  = regexp.MustCompile(cronRegexString) | ||||
| 	spicedbIDRegex             = regexp.MustCompile(spicedbIDRegexString) | ||||
| 	spicedbPermissionRegex     = regexp.MustCompile(spicedbPermissionRegexString) | ||||
| 	spicedbTypeRegex           = regexp.MustCompile(spicedbTypeRegexString) | ||||
| ) | ||||
|  |  | |||
							
								
								
									
										12
									
								
								vendor/github.com/go-playground/validator/v10/util.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/go-playground/validator/v10/util.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -261,13 +261,19 @@ func asUint(param string) uint64 { | |||
| 	return i | ||||
| } | ||||
| 
 | ||||
| // asFloat returns the parameter as a float64 | ||||
| // asFloat64 returns the parameter as a float64 | ||||
| // or panics if it can't convert | ||||
| func asFloat(param string) float64 { | ||||
| 
 | ||||
| func asFloat64(param string) float64 { | ||||
| 	i, err := strconv.ParseFloat(param, 64) | ||||
| 	panicIf(err) | ||||
| 	return i | ||||
| } | ||||
| 
 | ||||
| // asFloat64 returns the parameter as a float64 | ||||
| // or panics if it can't convert | ||||
| func asFloat32(param string) float64 { | ||||
| 	i, err := strconv.ParseFloat(param, 32) | ||||
| 	panicIf(err) | ||||
| 	return i | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										113
									
								
								vendor/github.com/go-playground/validator/v10/validator.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										113
									
								
								vendor/github.com/go-playground/validator/v10/validator.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -99,6 +99,8 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr | |||
| 
 | ||||
| 	current, kind, v.fldIsPointer = v.extractTypeInternal(current, false) | ||||
| 
 | ||||
| 	var isNestedStruct bool | ||||
| 
 | ||||
| 	switch kind { | ||||
| 	case reflect.Ptr, reflect.Interface, reflect.Invalid: | ||||
| 
 | ||||
|  | @ -160,86 +162,61 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr | |||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 	case reflect.Struct: | ||||
| 
 | ||||
| 		typ = current.Type() | ||||
| 
 | ||||
| 		if !typ.ConvertibleTo(timeType) { | ||||
| 
 | ||||
| 			if ct != nil { | ||||
| 
 | ||||
| 				if ct.typeof == typeStructOnly { | ||||
| 					goto CONTINUE | ||||
| 				} else if ct.typeof == typeIsDefault { | ||||
| 					// set Field Level fields | ||||
| 					v.slflParent = parent | ||||
| 					v.flField = current | ||||
| 					v.cf = cf | ||||
| 					v.ct = ct | ||||
| 
 | ||||
| 					if !ct.fn(ctx, v) { | ||||
| 						v.str1 = string(append(ns, cf.altName...)) | ||||
| 
 | ||||
| 						if v.v.hasTagNameFunc { | ||||
| 							v.str2 = string(append(structNs, cf.name...)) | ||||
| 						} else { | ||||
| 							v.str2 = v.str1 | ||||
| 						} | ||||
| 
 | ||||
| 						v.errs = append(v.errs, | ||||
| 							&fieldError{ | ||||
| 								v:              v.v, | ||||
| 								tag:            ct.aliasTag, | ||||
| 								actualTag:      ct.tag, | ||||
| 								ns:             v.str1, | ||||
| 								structNs:       v.str2, | ||||
| 								fieldLen:       uint8(len(cf.altName)), | ||||
| 								structfieldLen: uint8(len(cf.name)), | ||||
| 								value:          current.Interface(), | ||||
| 								param:          ct.param, | ||||
| 								kind:           kind, | ||||
| 								typ:            typ, | ||||
| 							}, | ||||
| 						) | ||||
| 						return | ||||
| 					} | ||||
| 				} | ||||
| 
 | ||||
| 				ct = ct.next | ||||
| 			} | ||||
| 
 | ||||
| 			if ct != nil && ct.typeof == typeNoStructLevel { | ||||
| 				return | ||||
| 			} | ||||
| 
 | ||||
| 		CONTINUE: | ||||
| 			// if len == 0 then validating using 'Var' or 'VarWithValue' | ||||
| 			// Var - doesn't make much sense to do it that way, should call 'Struct', but no harm... | ||||
| 			// VarWithField - this allows for validating against each field within the struct against a specific value | ||||
| 			//                pretty handy in certain situations | ||||
| 			if len(cf.name) > 0 { | ||||
| 				ns = append(append(ns, cf.altName...), '.') | ||||
| 				structNs = append(append(structNs, cf.name...), '.') | ||||
| 			} | ||||
| 
 | ||||
| 			v.validateStruct(ctx, parent, current, typ, ns, structNs, ct) | ||||
| 		if kind == reflect.Invalid { | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if ct == nil || !ct.hasTag { | ||||
| 		return | ||||
| 	case reflect.Struct: | ||||
| 		isNestedStruct = !current.Type().ConvertibleTo(timeType) | ||||
| 		// For backward compatibility before struct level validation tags were supported | ||||
| 		// as there were a number of projects relying on `required` not failing on non-pointer | ||||
| 		// structs. Since it's basically nonsensical to use `required` with a non-pointer struct | ||||
| 		// are explicitly skipping the required validation for it. This WILL be removed in the | ||||
| 		// next major version. | ||||
| 		if isNestedStruct && !v.v.requiredStructEnabled && ct != nil && ct.tag == requiredTag { | ||||
| 			ct = ct.next | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	typ = current.Type() | ||||
| 
 | ||||
| OUTER: | ||||
| 	for { | ||||
| 		if ct == nil { | ||||
| 		if ct == nil || !ct.hasTag || (isNestedStruct && len(cf.name) == 0) { | ||||
| 			// isNestedStruct check here | ||||
| 			if isNestedStruct { | ||||
| 				// if len == 0 then validating using 'Var' or 'VarWithValue' | ||||
| 				// Var - doesn't make much sense to do it that way, should call 'Struct', but no harm... | ||||
| 				// VarWithField - this allows for validating against each field within the struct against a specific value | ||||
| 				//                pretty handy in certain situations | ||||
| 				if len(cf.name) > 0 { | ||||
| 					ns = append(append(ns, cf.altName...), '.') | ||||
| 					structNs = append(append(structNs, cf.name...), '.') | ||||
| 				} | ||||
| 
 | ||||
| 				v.validateStruct(ctx, parent, current, typ, ns, structNs, ct) | ||||
| 			} | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		switch ct.typeof { | ||||
| 		case typeNoStructLevel: | ||||
| 			return | ||||
| 
 | ||||
| 		case typeStructOnly: | ||||
| 			if isNestedStruct { | ||||
| 				// if len == 0 then validating using 'Var' or 'VarWithValue' | ||||
| 				// Var - doesn't make much sense to do it that way, should call 'Struct', but no harm... | ||||
| 				// VarWithField - this allows for validating against each field within the struct against a specific value | ||||
| 				//                pretty handy in certain situations | ||||
| 				if len(cf.name) > 0 { | ||||
| 					ns = append(append(ns, cf.altName...), '.') | ||||
| 					structNs = append(append(structNs, cf.name...), '.') | ||||
| 				} | ||||
| 
 | ||||
| 				v.validateStruct(ctx, parent, current, typ, ns, structNs, ct) | ||||
| 			} | ||||
| 			return | ||||
| 
 | ||||
| 		case typeOmitEmpty: | ||||
| 
 | ||||
|  | @ -366,7 +343,7 @@ OUTER: | |||
| 						ct = ct.next | ||||
| 
 | ||||
| 						if ct == nil { | ||||
| 							return | ||||
| 							continue OUTER | ||||
| 						} | ||||
| 
 | ||||
| 						if ct.typeof != typeOr { | ||||
|  |  | |||
							
								
								
									
										32
									
								
								vendor/github.com/go-playground/validator/v10/validator_instance.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/go-playground/validator/v10/validator_instance.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -79,19 +79,20 @@ type internalValidationFuncWrapper struct { | |||
| 
 | ||||
| // Validate contains the validator settings and cache | ||||
| type Validate struct { | ||||
| 	tagName          string | ||||
| 	pool             *sync.Pool | ||||
| 	hasCustomFuncs   bool | ||||
| 	hasTagNameFunc   bool | ||||
| 	tagNameFunc      TagNameFunc | ||||
| 	structLevelFuncs map[reflect.Type]StructLevelFuncCtx | ||||
| 	customFuncs      map[reflect.Type]CustomTypeFunc | ||||
| 	aliases          map[string]string | ||||
| 	validations      map[string]internalValidationFuncWrapper | ||||
| 	transTagFunc     map[ut.Translator]map[string]TranslationFunc // map[<locale>]map[<tag>]TranslationFunc | ||||
| 	rules            map[reflect.Type]map[string]string | ||||
| 	tagCache         *tagCache | ||||
| 	structCache      *structCache | ||||
| 	tagName               string | ||||
| 	pool                  *sync.Pool | ||||
| 	tagNameFunc           TagNameFunc | ||||
| 	structLevelFuncs      map[reflect.Type]StructLevelFuncCtx | ||||
| 	customFuncs           map[reflect.Type]CustomTypeFunc | ||||
| 	aliases               map[string]string | ||||
| 	validations           map[string]internalValidationFuncWrapper | ||||
| 	transTagFunc          map[ut.Translator]map[string]TranslationFunc // map[<locale>]map[<tag>]TranslationFunc | ||||
| 	rules                 map[reflect.Type]map[string]string | ||||
| 	tagCache              *tagCache | ||||
| 	structCache           *structCache | ||||
| 	hasCustomFuncs        bool | ||||
| 	hasTagNameFunc        bool | ||||
| 	requiredStructEnabled bool | ||||
| } | ||||
| 
 | ||||
| // New returns a new instance of 'validate' with sane defaults. | ||||
|  | @ -99,7 +100,7 @@ type Validate struct { | |||
| // It caches information about your struct and validations, | ||||
| // in essence only parsing your validation tags once per struct type. | ||||
| // Using multiple instances neglects the benefit of caching. | ||||
| func New() *Validate { | ||||
| func New(options ...Option) *Validate { | ||||
| 
 | ||||
| 	tc := new(tagCache) | ||||
| 	tc.m.Store(make(map[string]*cTag)) | ||||
|  | @ -146,6 +147,9 @@ func New() *Validate { | |||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	for _, o := range options { | ||||
| 		o(v) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue