From 5e15a7ffc83531026d6cfa3305f0f7c7c249a9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 1 May 2024 22:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE=E7=BB=84?= =?UTF-8?q?=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define/rule.go | 2 +- handle_slice.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/define/rule.go b/define/rule.go index be8e184..cd4d1ae 100644 --- a/define/rule.go +++ b/define/rule.go @@ -21,6 +21,7 @@ type FieldRule struct { AllowEmpty bool `json:"allow_empty"` // 必传时空字符串是否合法 AllowZero bool `json:"allow_zero"` // 必传数字, 0 是否合法 AllowNil bool `json:"allow_nil"` // 必传时, nil值是否合法 + DisableAutoConvert bool `json:"disable_auto_convert"` // 禁用自动格式转换, 不禁用情况下, ["1","2","3"] 可以转换成 [1,2,3] , "12.34" 可以转换成 12.34 RequiredConditionGroup [][]RequiredCondition `json:"required_condition_group"` // 满足何种条件,字段必传,不配置则为无差别必传, 组之间是或条件, 满足一组即命中, 组之内为与条件 ValueLimit *ValueLimit `json:"value_limit"` // 数据值的限制 SliceConfig *SliceConfig `json:"slice_config"` // 数组转化的配置 @@ -76,6 +77,5 @@ type MapValueLimit struct { type SliceConfig struct { Mode string `json:"slice_mode"` // REAL - 输入直接是slice MARSHAL - json序列化之后的字符串 WITH_SPLIT_CHAR - 使用指定字符串分隔 DisableIgnoreEmpty bool `json:"disable_ignore_empty"` // 指定字符分割的时候, 忽略空字符串 - DisableAutoConvert bool `json:"disable_auto_convert"` // 禁用自动格式转换, 不禁用情况下, ["1","2","3"] 可以转换成 [1,2,3] SplitChar string `json:"split_char"` // 数组转换的分隔符, 当输入模式是 WITH_SPLIT_CHAR 时生效 } diff --git a/handle_slice.go b/handle_slice.go index 6f0859d..6d698bd 100644 --- a/handle_slice.go +++ b/handle_slice.go @@ -210,7 +210,6 @@ func handleSlice(inputValue interface{}, rule *define.FieldRule) ([]any, error) rule.SliceConfig = &define.SliceConfig{ Mode: consts.DataSliceModelMarshal, DisableIgnoreEmpty: false, - DisableAutoConvert: false, SplitChar: "", } } else {