validatePassword function
Implementation
String? validatePassword(BuildContext context, String? password) {
final RegExp passwordRegex = RegExp(r'^(?=.*?[a-zA-Z])(?=.*?[0-9]).{8,30}$');
if (password?.isEmpty == true) {
return S.of(context).please_enter_a_password;
}
if ((password?.length ?? 0) < 8) {
return S.of(context).password_must_be_at_least;
}
if ( !passwordRegex.hasMatch(password ?? "")) {
return S.of(context).password_must_be_content;
}
return null;
}