增加atring trim/convert 验证
This commit is contained in:
parent
4c70ca6f84
commit
d3be2ddb2d
49
run_test.go
49
run_test.go
@ -116,10 +116,6 @@ func TestRunRequired(t *testing.T) {
|
||||
AllowNil: false,
|
||||
DisableAutoTrimSpace: false,
|
||||
DisableAutoConvert: true,
|
||||
RequiredConditionGroup: nil,
|
||||
ValueLimit: nil,
|
||||
SliceConfig: nil,
|
||||
MapConfig: nil,
|
||||
},
|
||||
}
|
||||
err = Run(sourceData, ruleListForDisableAutoConvert, nil)
|
||||
@ -127,4 +123,49 @@ func TestRunRequired(t *testing.T) {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
assert.Error(t, err)
|
||||
|
||||
sourceData = map[string]interface{}{
|
||||
"name": " ",
|
||||
}
|
||||
ruleListForAllowTrim := []*define.FieldRule{
|
||||
&define.FieldRule{
|
||||
Path: "name",
|
||||
Type: "string",
|
||||
DisableRewrite: false,
|
||||
DefaultValue: nil,
|
||||
IsRequired: true,
|
||||
AllowEmpty: false,
|
||||
AllowZero: false,
|
||||
AllowNil: false,
|
||||
DisableAutoTrimSpace: false,
|
||||
DisableAutoConvert: true,
|
||||
},
|
||||
}
|
||||
err = Run(sourceData, ruleListForAllowTrim, nil)
|
||||
if nil != err {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
assert.Error(t, err)
|
||||
|
||||
sourceData = map[string]interface{}{
|
||||
"name": " ",
|
||||
}
|
||||
ruleListForDisableTrim := []*define.FieldRule{
|
||||
&define.FieldRule{
|
||||
Path: "name",
|
||||
Type: "string",
|
||||
DisableRewrite: false,
|
||||
DefaultValue: nil,
|
||||
IsRequired: true,
|
||||
AllowEmpty: false,
|
||||
AllowZero: false,
|
||||
AllowNil: false,
|
||||
DisableAutoTrimSpace: true,
|
||||
DisableAutoConvert: true,
|
||||
},
|
||||
}
|
||||
err = Run(sourceData, ruleListForDisableTrim, nil)
|
||||
if nil != err {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user