ValidatePassword 验证密码格式
()
| 72 | |
| 73 | // ValidatePassword 验证密码格式 |
| 74 | func (u *User) ValidatePassword() error { |
| 75 | passwordRegex := regexp2.MustCompile(passwordRegexPattern, regexp2.None) |
| 76 | isMatch, err := passwordRegex.MatchString(u.Password) |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | if !isMatch { |
| 81 | return ErrInvalidPasswordFormat |
| 82 | } |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | // VerifyPassword 验证密码是否匹配 |
| 87 | func (u *User) VerifyPassword(password string) error { |