入口处统一支持去空格

This commit is contained in:
白茶清欢 2024-05-16 20:46:53 +08:00
parent 2d8d05044c
commit 84d515bce2

5
run.go
View File

@ -131,8 +131,11 @@ func formatInputVal(val gjson.Result, rule *define.FieldRule) (any, error) {
inputVal = strings.TrimSpace(rule.DefaultValue) inputVal = strings.TrimSpace(rule.DefaultValue)
} }
} else { } else {
if !rule.DisableAutoConvert {
if inputValStr, ok := inputVal.(string); ok { if inputValStr, ok := inputVal.(string); ok {
if rule.AutoTrimSpace {
// 自动去空格
inputVal = strings.TrimSpace(inputValStr)
} else {
inputVal = inputValStr inputVal = inputValStr
} }
} }