* fix: #2672

* chore: fix more cases

* chore: update deps

* chore: update deps

* chore: refactor

* chore: refactor

* chore: refactor
This commit is contained in:
Kevin Wan
2022-12-11 00:41:50 +08:00
committed by GitHub
parent ef22042f4d
commit fdc57d07d7
14 changed files with 157 additions and 65 deletions

View File

@@ -82,7 +82,14 @@ func ValidatePtr(v *reflect.Value) error {
func convertType(kind reflect.Kind, str string) (interface{}, error) {
switch kind {
case reflect.Bool:
return str == "1" || strings.ToLower(str) == "true", nil
switch strings.ToLower(str) {
case "1", "true":
return true, nil
case "0", "false":
return false, nil
default:
return false, errTypeMismatch
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
intValue, err := strconv.ParseInt(str, 10, 64)
if err != nil {