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.5.0 to 1.7.0 (#2745)
This commit is contained in:
17
vendor/github.com/go-playground/validator/v10/util.go
generated
vendored
17
vendor/github.com/go-playground/validator/v10/util.go
generated
vendored
@ -1,7 +1,9 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -292,3 +294,18 @@ func panicIf(err error) {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if field value matches regex. If fl.Field can be cast to Stringer, it uses the Stringer interfaces
|
||||
// String() return value. Otherwise, it uses fl.Field's String() value.
|
||||
func fieldMatchesRegexByStringerValOrString(regex *regexp.Regexp, fl FieldLevel) bool {
|
||||
switch fl.Field().Kind() {
|
||||
case reflect.String:
|
||||
return regex.MatchString(fl.Field().String())
|
||||
default:
|
||||
if stringer, ok := fl.Field().Interface().(fmt.Stringer); ok {
|
||||
return regex.MatchString(stringer.String())
|
||||
} else {
|
||||
return regex.MatchString(fl.Field().String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user