Skip to content

Commit 393d283

Browse files
committed
fix: 修复表单正则验证规则
1 parent 64797ad commit 393d283

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
AppName = "QuarkGo"
2424

2525
// 版本号
26-
Version = "3.9.13"
26+
Version = "3.9.14"
2727

2828
// 包名
2929
PkgName = "github.com/quarkcloudio/quark-go/v3"

template/admin/resource/performs_validation.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package resource
33
import (
44
"encoding/json"
55
"errors"
6+
"regexp"
67
"strings"
78
"unicode/utf8"
89

@@ -65,6 +66,16 @@ func (p *Template) Validator(rules []rule.Rule, data map[string]interface{}) err
6566
}
6667
}
6768
}
69+
case "regexp":
70+
if fieldValue, ok := fieldValue.(string); ok {
71+
re := regexp.MustCompile(rule.Pattern)
72+
if !re.MatchString(fieldValue) {
73+
errMsg := rule.Message
74+
if errMsg != "" {
75+
result = errors.New(errMsg)
76+
}
77+
}
78+
}
6879
case "unique":
6980
var (
7081
table string

0 commit comments

Comments
 (0)