Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultRule ¶
type DefaultRule struct {
// 验证的字段名
Key string
// 翻译后的字段名
// 默认 = Key
Trans string
// 规则
Valid string
}
内置规则结构 实现ValidateRuler接口
func (*DefaultRule) Check ¶
func (n *DefaultRule) Check(data interface{}) (err error)
common rule
字段值转换成string进行验证
type ValidError ¶
valid error
func ValidModel ¶
func ValidModel(data interface{}, model interface{}) ValidError
form/single json data
type ValidateRuler ¶
type ValidateRuler interface {
// 验证字段
Check(data interface{}) error
}
校验规则接口 支持自定义规则
Click to show internal directories.
Click to hide internal directories.