Exemple #1
0
        /// <summary>
        /// Builds new IBAN instance
        /// </summary>
        /// <param name="validate">True if the generated IBAN will be validated after generation</param>
        /// <returns>New IBAN instance</returns>
        /// <exception cref="IbanFormatException">If values doesn't meet requirements for valid IBAN.</exception>
        /// <exception cref="UnsupportedCountryException">If specified country code is not supported.</exception>
        public Iban Build(bool validate)
        {
            require(_countryCodeEntry, _bankCode, _accountNumber);

            string formattedIban = formatIban();
            string checkDigit    = IbanUtils.CalculateCheckDigit(formattedIban);
            string ibanValue     = IbanUtils.ReplaceCheckDigit(formattedIban, checkDigit);

            if (validate)
            {
                IbanUtils.Validate(ibanValue);
            }

            return(Iban.CreateInstance(ibanValue));
        }
Exemple #2
0
 /// <summary>
 /// Calculates IBAN's check digit.
 /// ISO13616
 /// </summary>
 /// <param name="iban">IBAN object</param>
 /// <returns>Check digit as string</returns>
 /// <exception cref="IbanFormatException">Thrown if supplied iban string contains invalid chracters</exception>
 public static string CalculateCheckDigit(Iban iban) => CalculateCheckDigit(iban.ToString());