Documentation ¶
Overview ¶
Package define ...
Description : define ...
Author : go_developer@163.com<白茶清欢>
Date : 2024-04-29 10:51
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldRule ¶
type FieldRule struct { Path string `json:"path"` // 字段路径 Type consts.DataType `json:"type"` // 数据类型, 具体枚举值参见 git.zhangdeman.cn/zhangdeman/consts DisableRewrite bool `json:"disable_rewrite"` // 验证完相关数据类型之后, 不要重新给字段赋值 DefaultValue any `json:"default_value"` // 默认值, 统一以字符串传入, 会转为最终设置的类型 IsRequired bool `json:"is_required"` // 是否必传 AllowEmpty bool `json:"allow_empty"` // 必传时空字符串是否合法 AllowZero bool `json:"allow_zero"` // 必传数字, 0 是否合法 AllowNil bool `json:"allow_nil"` // 必传时, nil值是否合法 DisableAutoTrimSpace bool `json:"disable_auto_trim_space"` // 自动去除前后空格 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"` // 数组转化的配置 MapConfig *MapConfig `json:"map_config"` // 转换对象的配置 }
FieldRule 字段验证规则
Author : go_developer@163.com<白茶清欢>
Date : 10:52 2024/4/29
type MapConfig ¶
type MapConfig struct {
Mode string `json:"mode"` // REAL - 输入直接是map MARSHAL - json序列化之后的字符串
}
MapConfig map配置
Author : go_developer@163.com<白茶清欢>
Date : 11:18 2024/6/23
type MapValueLimit ¶
type MapValueLimit struct {
IncludeFieldList []string `json:"include_field_list"` // 必须存在的字段列表
}
MapValueLimit map数据的限制
Author : go_developer@163.com<白茶清欢>
Date : 11:23 2024/4/29
type RequiredCondition ¶
type RequiredCondition struct { DependOnField string `json:"depend_on_field"` // 依赖数据源中的那一个字段 DependOnFieldType consts.DataType `json:"depend_on_field_type"` // 依赖数据源数据类型 DependOnFieldStatus []string `json:"depend_on_field_status"` // 依赖数据状态 : NOT_FOUND / IS_NIL / IS_ZERO / IS_EMPTY / IS_FALSE }
RequiredCondition 定义必传条件
Author : zhangdeman001@ke.com<张德满>
Date : 10:58 2024/4/29
type SliceConfig ¶
type SliceConfig struct { Mode string `json:"mode"` // REAL - 输入直接是slice MARSHAL - json序列化之后的字符串 WITH_SPLIT_CHAR - 使用指定字符串分隔 DisableIgnoreEmpty bool `json:"disable_ignore_empty"` // 指定字符分割的时候, 忽略空字符串 SplitChar string `json:"split_char"` // 数组转换的分隔符, 当输入模式是 WITH_SPLIT_CHAR 时生效 }
SliceConfig slice的配置
Author : go_developer@163.com<白茶清欢>
Date : 21:34 2024/4/30
type StringValueLimit ¶
type StringValueLimit struct { IncludeSubStrList []string `json:"include_sub_str_list"` // 必须包含指定的子串, 必须全部包含 NotIncludeSubStrList []string `json:"not_include_sub_str_list"` // 必须不能包含的子串, 包含任意一个都不行 }
StringValueLimit 字符串类型值的限制
Author : go_developer@163.com<白茶清欢>
Date : 11:16 2024/4/29
type ValueLimit ¶
type ValueLimit struct { EnumList []string `json:"enum_list"` // 枚举值列表, 仅对 int / float / string 生效 Min *float64 `json:"min"` // 最小值(包含), 对于 int/float, 此值为最小取值, 对于int/map/slice辞职问最小长度 Max *float64 `json:"max"` // 最大值(不包含), 对于 int/float, 此值为最大取值, 对于int/map/slice辞职问最大长度 String *StringValueLimit `json:"string"` // 字符串值的限制 Map *MapValueLimit `json:"map"` // map验证 }
ValueLimit 取值的限制
Author : go_developer@163.com<白茶清欢>
Date : 11:15 2024/4/29