func (this *Member) validate(v *member.ValueMember) error { v.Usr = strings.ToLower(strings.TrimSpace(v.Usr)) // 小写并删除空格 v.Name = strings.TrimSpace(v.Name) v.Email = strings.ToLower(strings.TrimSpace(v.Email)) v.Phone = strings.TrimSpace(v.Phone) if len([]rune(v.Usr)) < 6 { return member.ErrUserLength } if !userRegex.MatchString(v.Usr) { return member.ErrUserValidErr } if this.GetAggregateRootId() != 0 && len([]rune(v.Name)) < 2 { return member.ErrPersonName } if len(v.Email) != 0 && !emailRegex.MatchString(v.Email) { return member.ErrEmailValidErr } if len(v.Phone) != 0 && !phoneRegex.MatchString(v.Phone) { return member.ErrPhoneValidErr } if len(v.Qq) != 0 && !qqRegex.MatchString(v.Qq) { return member.ErrQqValidErr } return nil }