QinGang_interested/lib/services/password_policy.dart

19 lines
535 B
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class PasswordPolicy {
static const defaultPassword = 'Cc@12345678';
static final RegExp _validPassword = RegExp(
r'^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!#@*&])[A-Za-z\d!#@*&]{8,16}$',
);
static bool requiresChange(String? password) {
return password == defaultPassword;
}
static String? validate(String password) {
if (_validPassword.hasMatch(password)) {
return null;
}
return '密码长度为8-16位且必须包含大写字母、小写字母、数字和特殊符号!#@*&)。';
}
}