feat: 数据判断功能库

main
熊二 1 year ago
parent 32a7f7d6fc
commit b93b1d8ec1
  1. 2
      pkg/is/is.go
  2. 2
      pkg/is/util.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. // 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 { func JSON[T any](t T) bool {
rv := reflect.ValueOf(t) rv := reflect.ValueOf(t)
if rv.Type() == bytesType { if rv.Type() == nilType {
return json.Valid(rv.Bytes()) return json.Valid(rv.Bytes())
} }
if rv.Kind() == reflect.String { if rv.Kind() == reflect.String {

@ -16,7 +16,7 @@ var (
ErrBadRange = errors.New("bad value range") ErrBadRange = errors.New("bad value range")
timeType = reflect.TypeOf(time.Time{}) timeType = reflect.TypeOf(time.Time{})
//nilType = reflect.TypeOf([]byte(nil)) nilType = reflect.TypeOf([]byte(nil))
) )
// convert value to float64, return error on failed // convert value to float64, return error on failed

Loading…
Cancel
Save