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.
|
|
using System.Text.RegularExpressions;
namespace Business.KftcPasswordRule { /// <summary>
/// </summary>
public class AtLeastOneNumberRule : PasswordRule { private string pattern = "[0-9]";
/// <summary>
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public PasswordValidationResult Validate(ValidationModel model) { if (model == null) { return new PasswordValidationResult { IsValid = false, Message = "invalid password.Atleast one number required. " }; }
if (string.IsNullOrEmpty(model.Password)) { return new PasswordValidationResult { IsValid = false, Message = "invalid password.Atleast one number required. " }; } var res = Regex.Matches(model.Password, pattern); if (res.Count > 0) { return new PasswordValidationResult { IsValid = true, Message = "valid" }; } return new PasswordValidationResult { IsValid = false, Message = "invalid password.Atleast one number required." }; } } }
|