字符串验证 : 支持配置参数传了的场景下,不允许为空验证
This commit is contained in:
@ -116,6 +116,11 @@ func handleString(inputVal any, rule *define.FieldRule) (string, error) {
|
||||
if err = util.ConvertAssign(&formatData, inputVal); nil != err {
|
||||
return "", err
|
||||
}
|
||||
// 判断空字符串
|
||||
if !rule.AllowEmpty && formatData == "" && rule.IsRequired {
|
||||
// 必传且不允许空字符串
|
||||
return "", fmt.Errorf("%v : data type is string empty, field is required and empty value is not allowed", rule.Path)
|
||||
}
|
||||
if nil == rule.ValueLimit {
|
||||
return formatData, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user