public static ValidationStatus PassportNoAndMzrMustMatch(MzrInput input) { var inputPassport = Helper.GetPassportNo(input); var paddedPassport = Helper.InputPad(input.PassportNo, 9); return(inputPassport == paddedPassport ? ValidationStatus.Valid : ValidationStatus.Warning); }
public static string GetPassportCheckDigit(MzrInput input) { if (input.Mzr.Length < 10) { return(""); } return(input.Mzr.Substring(9, 1)); }
public static ValidationStatus PassportCheckDigitMustCalcluate(MzrInput input) { var inputPassport = Helper.GetPassportNo(input); var inputPassportCheckDigit = Helper.GetPassportCheckDigit(input); var calculatedPassportCheckDigit = Helper.CalculateCheckDigit(inputPassport); Int16.TryParse(inputPassportCheckDigit, out Int16 inputPassportCheckDigitInt); return(inputPassportCheckDigitInt == calculatedPassportCheckDigit ? ValidationStatus.Valid : ValidationStatus.Error); }
public static string GetPassportNo(MzrInput input) { var length = Math.Min(9, input.Mzr.Length); return(input.Mzr.Substring(0, length)); }
public static ValidationStatus PassportCheckDigitMustBeNumeric(MzrInput input) { var inputPassportCheckDigit = Helper.GetPassportCheckDigit(input); return(Int16.TryParse(inputPassportCheckDigit, out _) ? ValidationStatus.Valid : ValidationStatus.Error); }
public static ValidationStatus LengthMustBe44Characters(MzrInput input) { var valid = input.Mzr.Length == 44; return(valid ? ValidationStatus.Valid : ValidationStatus.Error); }
public static ValidationStatus MustHaveAZ09LessThan(MzrInput input) { var valid = Regex.IsMatch(input.Mzr, "^[0-9A-Z<]+$"); return(valid ? ValidationStatus.Valid : ValidationStatus.Error); }
public static ValidationResult[] Validate(MzrInput input) { return(validator.Validate(input)); }