1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 02:20:19 +00:00

验证调整,增加label, xx不能为空

This commit is contained in:
Liu Zhang
2020-01-17 16:47:19 +08:00
parent aa90c67a75
commit 034599ca1d
4 changed files with 26 additions and 10 deletions

View File

@ -267,15 +267,16 @@ func (v *Validation) apply(chk Validator, obj interface{}) *Result {
key := chk.GetKey()
Name := key
Field := ""
Label := ""
parts := strings.Split(key, ".")
if len(parts) == 2 {
if len(parts) == 3 {
Field = parts[0]
Name = parts[1]
Label = parts[2]
}
err := &Error{
Message: chk.DefaultMessage(),
Message: Label + chk.DefaultMessage(),
Key: key,
Name: Name,
Field: Field,
@ -298,7 +299,7 @@ func (v *Validation) AddError(key, message string) {
Field := ""
parts := strings.Split(key, ".")
if len(parts) == 2 {
if len(parts) == 3 {
Field = parts[0]
Name = parts[1]
}