Exemple #1
0
        /// <summary>
        /// Check for required fields.
        /// Every broken rule throws exception
        /// </summary>
        /// <param name="countryCodeEntry">Country code Entry</param>
        /// <param name="bankCode">Bank code</param>
        /// <param name="accountNumber">Account number</param>
        /// <exception cref="IbanFormatException">Thrown when one of the parameters is not supplied</exception>
        private void require(CountryCodeEntry countryCodeEntry, string bankCode, string accountNumber)
        {
            if (_countryCodeEntry == null)
            {
                throw new IbanFormatException( "Country code is required, it cannot be null.", IbanFormatViolation.COUNTRY_CODE_NOT_NULL );
            }

            if (string.IsNullOrEmpty(bankCode))
            {
                throw new IbanFormatException( "Bank code is required, it cannot be empty.", IbanFormatViolation.BANK_CODE_NOT_NULL );
            }

            if (string.IsNullOrEmpty(accountNumber))
            {
                throw new IbanFormatException( "Account number is required, it cannot be empty.", IbanFormatViolation.ACCOUNT_NUMBER_NOT_NULL );
            }
        }
Exemple #2
0
 /// <summary>
 /// Sets iban's Country code 
 /// </summary>
 /// <param name="countryCode">Country code entry</param>
 /// <returns>Builder instance</returns>
 public IbanBuilder CountryCode(CountryCodeEntry countryCode)
 {
     this._countryCodeEntry = countryCode;
     return this;
 }
Exemple #3
0
 private static BBanStructure getBbanStructure (CountryCodeEntry countryCode) => Bban.GetStructureForCountry( countryCode );
Exemple #4
0
        /// <summary>
        /// Returns IBAN length for the specified country
        /// </summary>
        /// <param name="countryCode">Country code object</param>
        /// <returns>The length of IBAN for the specified country</returns>
        public static int GetIbanLength (CountryCodeEntry countryCode)
        {
            int result = 0;
            BBanStructure structure = getBbanStructure( countryCode );

            if (structure != null)
            {
                result = _COUNTRY_CODE_LENGTH + _CHECK_DIGIT_LENGTH + structure.GetBBanLength();
            }

            return result;
        }
Exemple #5
0
 /// <summary>
 /// Checks whether country is supported.
 /// It is checked by trying to find the country code in defined BBAN structures.
 /// </summary>
 /// <param name="countryCode">Country code object</param>
 /// <returns>True if country code is supported, othewise false</returns>
 public static bool IsSupportedCountry (CountryCodeEntry countryCode) => (CountryCode.GetCountryCode(countryCode?.Alpha2) != null) && (Bban.GetStructureForCountry( countryCode ) != null);
Exemple #6
0
        /// <summary>
        /// Search for BBAN structure of specified country
        /// </summary>
        /// <param name="countryCode">Country code object</param>
        /// <returns>BBAN structure of defined country, or null if given country code is unsupported</returns>
        public static BBanStructure GetStructureForCountry (CountryCodeEntry countryCode)
        {
            Bban bban = new Bban();
            BBanStructure result = null;

            if (countryCode != null)
            {
                if (bban._bbanStructures != null)
                {
                    if (bban._bbanStructures.ContainsKey( countryCode.Alpha2 ))
                    {
                        result = bban._bbanStructures[countryCode.Alpha2];
                    }
                }
            }
            
            return result;
        }