namespace Business.KftcPasswordRule
{
///
///
public class IdNumberRule : PasswordRule
{
///
///
///
///
public PasswordValidationResult Validate(ValidationModel model)
{
if (model.IdType.ToLower() == "passport")
{
if (model.Password.Contains(model.IdNumber))
{
return new PasswordValidationResult { IsValid = false, Message = "Password can not be same as id Number!" };
}
}
string idFirstPart = model.IdNumber.Substring(0, 6);
string idSecondPart = model.IdNumber.Substring(6, model.IdNumber.Length - 6);
if (model.Password.Contains(idFirstPart))
{
return new PasswordValidationResult { IsValid = false, Message = "Password can not be same as id Number!" };
}
if (model.Password.Contains(idSecondPart))
{
return new PasswordValidationResult { IsValid = false, Message = "Password can not be same as id Number!" };
}
return new PasswordValidationResult { IsValid = true, Message = "valid" };
}
}
}