diff --git a/pkg/is/is.go b/pkg/is/is.go index 379dd93..61bd3af 100644 --- a/pkg/is/is.go +++ b/pkg/is/is.go @@ -286,7 +286,7 @@ func Longitude[T any](t T) bool { // JSON is the validation function for validating if the current field's value is a valid json string. func JSON[T any](t T) bool { rv := reflect.ValueOf(t) - if rv.Type() == bytesType { + if rv.Type() == nilType { return json.Valid(rv.Bytes()) } if rv.Kind() == reflect.String { diff --git a/pkg/is/util.go b/pkg/is/util.go index 3d180e8..421c93d 100644 --- a/pkg/is/util.go +++ b/pkg/is/util.go @@ -16,7 +16,7 @@ var ( ErrBadRange = errors.New("bad value range") timeType = reflect.TypeOf(time.Time{}) - //nilType = reflect.TypeOf([]byte(nil)) + nilType = reflect.TypeOf([]byte(nil)) ) // convert value to float64, return error on failed