InputValidation.strongPassword constructor

InputValidation.strongPassword({
  1. String? errorMsg,
  2. String? emptyTip,
  3. bool mustFill = true,
  4. int minLength = 8,
})

密码强度校验 / Password strength validation

要求:至少8位,包含大小写字母、数字和特殊字符 Requirements: At least 8 characters, including uppercase, lowercase, numbers and special characters

Example:

validator: InputValidation.strongPassword(errorMsg: "密码强度不够").validate

Implementation

factory InputValidation.strongPassword({
  String? errorMsg,
  String? emptyTip,
  bool mustFill = true,
  int minLength = 8,
}) {
  return InputValidation(
    mustFill: mustFill,
    regExp: RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{' + minLength.toString() + r',}$'),
    errorMsg: errorMsg ?? "密码至少${minLength}位,需包含大小写字母、数字和特殊字符",
    emptyTip: emptyTip ?? "密码不能为空",
  );
}