mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 02:20:19 +00:00
验证调整,增加label, xx不能为空
This commit is contained in:
@ -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]
|
||||
}
|
||||
|
Reference in New Issue
Block a user