mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02: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:
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()
|
||||
|
Reference in New Issue
Block a user