Validate checks that the plain text password meets the minimum password requirements. It returns properly formatted errors for detailed form validation on the client.
(password string)
| 138 | // Validate checks that the plain text password meets the minimum password requirements. |
| 139 | // It returns properly formatted errors for detailed form validation on the client. |
| 140 | func Validate(password string) error { |
| 141 | // Ensure passwords are secure enough! |
| 142 | // See: https://github.com/wagslane/go-password-validator#what-entropy-value-should-i-use |
| 143 | err := passwordvalidator.Validate(password, 52) |
| 144 | if err != nil { |
| 145 | return err |
| 146 | } |
| 147 | if len(password) > 64 { |
| 148 | return xerrors.Errorf("password must be no more than %d characters", 64) |
| 149 | } |
| 150 | return nil |
| 151 | } |