增加atring trim/convert 验证
This commit is contained in:
parent
4c70ca6f84
commit
d3be2ddb2d
69
run_test.go
69
run_test.go
@ -106,20 +106,16 @@ func TestRunRequired(t *testing.T) {
|
||||
}
|
||||
ruleListForDisableAutoConvert := []*define.FieldRule{
|
||||
&define.FieldRule{
|
||||
Path: "name",
|
||||
Type: "string",
|
||||
DisableRewrite: false,
|
||||
DefaultValue: nil,
|
||||
IsRequired: true,
|
||||
AllowEmpty: false,
|
||||
AllowZero: false,
|
||||
AllowNil: false,
|
||||
DisableAutoTrimSpace: false,
|
||||
DisableAutoConvert: true,
|
||||
RequiredConditionGroup: nil,
|
||||
ValueLimit: nil,
|
||||
SliceConfig: nil,
|
||||
MapConfig: nil,
|
||||
Path: "name",
|
||||
Type: "string",
|
||||
DisableRewrite: false,
|
||||
DefaultValue: nil,
|
||||
IsRequired: true,
|
||||
AllowEmpty: false,
|
||||
AllowZero: false,
|
||||
AllowNil: false,
|
||||
DisableAutoTrimSpace: false,
|
||||
DisableAutoConvert: true,
|
||||
},
|
||||
}
|
||||
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