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.
33 lines
1.3 KiB
33 lines
1.3 KiB
namespace Business.KftcPasswordRule
|
|
{
|
|
/// <summary>
|
|
/// </summary>
|
|
public class IdNumberRule : PasswordRule
|
|
{
|
|
/// <summary>
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
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" };
|
|
}
|
|
}
|
|
}
|