mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-11 11:43:46 +08:00
添加yaml字段类型
This commit is contained in:
@@ -30,6 +30,7 @@ const (
|
||||
InputTypeInsertFields = 6 // 编辑新增过滤字段
|
||||
InputTypeTreeOptionFields = 7 // 关系树查询字段
|
||||
EditInpValidatorGenerally = "if err := g.Validator().Rules(\"%s\").Data(in.%s).Messages(\"%s\").Run(ctx); err != nil {\n\t\treturn err.Current()\n\t}\n"
|
||||
EditInpValidatorYaml = "if err := validate.ValidateYAML(in.%s); err != nil {\n\t\treturn gerror.Newf(\"%s必须为有效的YAML格式: %%s\", err.Error())\n\t}\n"
|
||||
)
|
||||
|
||||
func (l *gCurd) inputTplData(ctx context.Context, in *CurdPreviewInput) (data g.Map, err error) {
|
||||
@@ -308,6 +309,8 @@ func makeValidatorFunc(field *sysin.GenCodesColumnListModel) (err error, rule st
|
||||
rule = fmt.Sprintf(EditInpValidatorGenerally, "regex:^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,18}$", field.GoName, field.Dc+"必须包含6-18为字母和数字")
|
||||
} else if field.FormRole == FormRoleAmount {
|
||||
rule = fmt.Sprintf(EditInpValidatorGenerally, "regex:(^[0-9]{1,10}$)|(^[0-9]{1,10}[\\\\.]{1}[0-9]{1,2}$)", field.GoName, field.Dc+"最多允许输入10位整数及2位小数")
|
||||
} else if field.FormRole == FormRoleYaml {
|
||||
rule = fmt.Sprintf(EditInpValidatorYaml, field.GoName, field.Dc)
|
||||
} else {
|
||||
err = gerror.New("not support")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user