/// <summary>
        /// Determines whether the specified account number is valid.
        /// </summary>
        /// <param name="accountNumber">The account number.</param>
        /// <returns>
        ///   <c>true</c> if the specified account number is valid; otherwise, <c>false</c>.
        /// </returns>
        virtual public bool IsValid(string accountNumber)
        {
            string number;
            string checkdigit;

            ValidationMethodsTools.SplitNumber(accountNumber, 1, out number, out checkdigit);

            var calculatedCheckDigit = CalculateCheckDigitInternal(number).ToString();

            return(calculatedCheckDigit.Equals(checkdigit));
        }
Пример #2
0
        /// <summary>
        /// Determines whether the specified account number is valid.
        /// </summary>
        /// <param name="accountNumber">The account number.</param>
        /// <returns>
        ///   <c>true</c> if the specified account number is valid; otherwise, <c>false</c>.
        /// </returns>
        virtual public bool IsValid(string accountNumber)
        {
            string number;
            string checkdigit;

            ValidationMethodsTools.SplitNumber(accountNumber, 2, out number, out checkdigit);

            var calculatedCheckDigit = ValidationMethodsTools.CalculateModulo(number, 97).ToString("00");

            Log.InfoFormat("Validate {0} against check digits {1}, calculated check digits {2}", number, checkdigit, calculatedCheckDigit);

            return(calculatedCheckDigit.Equals(checkdigit));
        }
Пример #3
0
        /// <summary>
        /// Determines whether the specified credit card number is formal valid.
        /// </summary>
        /// <param name="creditCardNumber">The credit card number.</param>
        /// <returns>
        ///   <c>true</c> if the specified credit card number is formal valid; otherwise, <c>false</c>.
        /// </returns>
        public bool IsValid(string creditCardNumber)
        {
            if (creditCardNumber.Length < minLength || creditCardNumber.Length > maxLength)
            {
                return(false);
            }

            string number;
            string checkdigit;

            ValidationMethodsTools.SplitNumber(creditCardNumber, 1, out number, out checkdigit);

            var calculatedCheckDigit = CalculateCheckDigitInternal(number).ToString();

            return(calculatedCheckDigit.Equals(checkdigit));
        }