コード例 #1
0
        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);
        }
コード例 #2
0
        public static string GetPassportCheckDigit(MzrInput input)
        {
            if (input.Mzr.Length < 10)
            {
                return("");
            }

            return(input.Mzr.Substring(9, 1));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public static string GetPassportNo(MzrInput input)
        {
            var length = Math.Min(9, input.Mzr.Length);

            return(input.Mzr.Substring(0, length));
        }
コード例 #5
0
        public static ValidationStatus PassportCheckDigitMustBeNumeric(MzrInput input)
        {
            var inputPassportCheckDigit = Helper.GetPassportCheckDigit(input);

            return(Int16.TryParse(inputPassportCheckDigit, out _) ? ValidationStatus.Valid : ValidationStatus.Error);
        }
コード例 #6
0
        public static ValidationStatus LengthMustBe44Characters(MzrInput input)
        {
            var valid = input.Mzr.Length == 44;

            return(valid ? ValidationStatus.Valid : ValidationStatus.Error);
        }
コード例 #7
0
        public static ValidationStatus MustHaveAZ09LessThan(MzrInput input)
        {
            var valid = Regex.IsMatch(input.Mzr, "^[0-9A-Z<]+$");

            return(valid ? ValidationStatus.Valid : ValidationStatus.Error);
        }
コード例 #8
0
 public static ValidationResult[] Validate(MzrInput input)
 {
     return(validator.Validate(input));
 }