예제 #1
0
        public override string GetRandomDriversLicense()
        {
            var dlVal    = base.GetRandomDriversLicense();
            var chkDigit = NfString.CalcLuhnCheckDigit(dlVal);
            var dlOut    = new StringBuilder();

            dlOut.Append(dlVal);
            dlOut.Append(chkDigit.ToString());
            return(dlOut.ToString());
        }
예제 #2
0
        public override bool ValidDriversLicense(string dlnumber)
        {
            if (string.IsNullOrWhiteSpace(dlnumber))
            {
                return(false);
            }
            //all but last digit
            var dlVal = dlnumber.Substring(0, dlnumber.Length - 1);

            var dlLastChar = dlnumber.Substring(dlnumber.Length - 1, 1);
            var dlChkDigit = 0;

            if (!int.TryParse(dlLastChar, out dlChkDigit))
            {
                return(false);
            }

            var calcChkDigit = NfString.CalcLuhnCheckDigit(dlVal);

            return(base.ValidDriversLicense(dlVal) && dlChkDigit == calcChkDigit);
        }