You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

1 year ago
  1. using System.Text.RegularExpressions;
  2. namespace Business.KftcPasswordRule
  3. {
  4. /// <summary>
  5. /// </summary>
  6. public class AtLeastOneLowerCaseRule : PasswordRule
  7. {
  8. private string pattern = "[a-z]";
  9. /// <summary>
  10. /// </summary>
  11. /// <param name="model"></param>
  12. /// <returns></returns>
  13. public PasswordValidationResult Validate(ValidationModel model)
  14. {
  15. if (model == null)
  16. {
  17. return new PasswordValidationResult { IsValid = false, Message = "Invalid password.Atleast one lowercase required. " };
  18. }
  19. if (string.IsNullOrEmpty(model.Password))
  20. {
  21. return new PasswordValidationResult { IsValid = false, Message = "Invalid password.Atleast one lowercase required. " };
  22. }
  23. var res = Regex.Matches(model.Password, pattern);
  24. if (res.Count > 0)
  25. {
  26. return new PasswordValidationResult { IsValid = true, Message = "valid" };
  27. }
  28. return new PasswordValidationResult { IsValid = false, Message = "invalid password.Atleast one lowercase required." };
  29. }
  30. }
  31. }