From 84d515bce2e1a65105845c24f1585bbac3c5f789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 16 May 2024 20:46:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=A4=84=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8E=BB=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run.go b/run.go index f79e9bd..ab268ed 100644 --- a/run.go +++ b/run.go @@ -131,8 +131,11 @@ func formatInputVal(val gjson.Result, rule *define.FieldRule) (any, error) { inputVal = strings.TrimSpace(rule.DefaultValue) } } 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 } }