Ai
1 Star 1 Fork 1

c./goframe框架

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
builtin_regex.go 897 Bytes
Copy Edit Raw Blame History
admin authored 2024-11-08 04:16 +08:00 . 2024-11-7
// 版权归GoFrame作者(https://goframe.org)所有。保留所有权利。
//
// 本源代码形式受MIT许可证条款约束。
// 如果未随本文件一同分发MIT许可证副本,
// 您可以在https://github.com/gogf/gf处获取。
// md5:a9832f33b234e3f3
package builtin
import (
"errors"
gregex "gitee.com/go_888/goframe/text/gregex"
)
// RuleRegex 实现了 `regex` 规则:
// 值应该匹配自定义的正则表达式模式。
//
// 格式:regex:pattern
// md5:51f168fc18898499
type RuleRegex struct{}
func init() {
Register(RuleRegex{})
}
func (r RuleRegex) Name() string {
return "regex"
}
func (r RuleRegex) Message() string {
return "{field}字段值`{value}`字段值不满足规则:{pattern}"
}
func (r RuleRegex) Run(in RunInput) error {
if !gregex.X是否匹配文本(in.RulePattern, in.Value.String()) {
return errors.New(in.Message)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/go_888/goframe.git
git@gitee.com:go_888/goframe.git
go_888
goframe
goframe框架
782a3f7170cf

Search