mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
Update validator.v8 升级为 validator.v9
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
package param_verify
|
||||
|
||||
import (
|
||||
"gopkg.in/go-playground/validator.v8"
|
||||
"reflect"
|
||||
"gopkg.in/go-playground/validator.v9"
|
||||
)
|
||||
|
||||
func NameValid (
|
||||
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
|
||||
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
|
||||
) bool {
|
||||
if s, ok := field.Interface().(string); ok {
|
||||
if s == "admin" {
|
||||
return false
|
||||
}
|
||||
func NameValid(fl validator.FieldLevel) bool {
|
||||
val := fl.Field().String()
|
||||
if val == "admin" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user