mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-20 00:02:16 +08:00
Update validate_test.go
This commit is contained in:
parent
3d97125470
commit
ea2b6370a9
@ -6,7 +6,6 @@ package binding
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -200,15 +199,8 @@ type structCustomValidation struct {
|
|||||||
Integer int `binding:"notone"`
|
Integer int `binding:"notone"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// notOne is a custom validator meant to be used with `validator.v8` library.
|
func notOne(f1 validator.FieldLevel) bool {
|
||||||
// The method signature for `v9` is significantly different and this function
|
if val, ok := f1.Field().Interface().(int); ok {
|
||||||
// would need to be changed for tests to pass after upgrade.
|
|
||||||
// See https://github.com/gin-gonic/gin/pull/1015.
|
|
||||||
func notOne(
|
|
||||||
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
|
|
||||||
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
|
|
||||||
) bool {
|
|
||||||
if val, ok := field.Interface().(int); ok {
|
|
||||||
return val != 1
|
return val != 1
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user