Esempio n. 1
0
        private static bool hasValidCountryCode(string iban, out IbanFormatViolation validationResult)
        {
            validationResult = IbanFormatViolation.NO_VIOLATION;

            if (iban.Length < _COUNTRY_CODE_LENGTH)
            {
                validationResult = IbanFormatViolation.COUNTRY_CODE_TWO_LETTERS;
            }
            else
            {
                string countryCode = GetCountryCode(iban);
                if (!countryCode.Equals(countryCode.ToUpper()) || !char.IsLetter(iban[0]) || !char.IsLetter(iban[1]))
                {
                    validationResult = IbanFormatViolation.COUNTRY_CODE_UPPER_CASE_LETTERS;
                }
                else
                {
                    CountryCodeEntry countryEntry = CountryCode.GetCountryCode(countryCode);
                    if (countryEntry == null)
                    {
                        validationResult = IbanFormatViolation.COUNTRY_CODE_EXISTS;
                    }
                    else
                    {
                        BBanStructure structure = Bban.GetStructureForCountry(countryEntry);
                        if (structure == null)
                        {
                            validationResult = IbanFormatViolation.COUNTRY_CODE_UNSUPPORTED;
                        }
                    }
                }
            }

            return(validationResult == IbanFormatViolation.NO_VIOLATION);
        }
Esempio n. 2
0
        private static void validateCountryCode(string iban)
        {
            if (iban.Length < _COUNTRY_CODE_LENGTH)
            {
                throw new IbanFormatException("Input must contain 2 letters for country code", IbanFormatViolation.COUNTRY_CODE_TWO_LETTERS, iban);
            }

            string countryCode = GetCountryCode(iban);

            if (!countryCode.Equals(countryCode.ToUpper()) || !char.IsLetter(iban[0]) || !char.IsLetter(iban[1]))
            {
                throw new IbanFormatException("IBAN's country code must contain upper case letters", IbanFormatViolation.COUNTRY_CODE_UPPER_CASE_LETTERS, iban);
            }

            CountryCodeEntry countryEntry = CountryCode.GetCountryCode(countryCode);

            if (countryEntry == null)
            {
                throw new IbanFormatException("IBAN contains non existing country code", IbanFormatViolation.COUNTRY_CODE_EXISTS, iban);
            }

            BBanStructure structure = Bban.GetStructureForCountry(countryEntry);

            if (structure == null)
            {
                throw new UnsupportedCountryException("IBAN contains not supported country code", countryCode);
            }
        }
Esempio n. 3
0
        private static void validateCountryCode(string bic)
        {
            string countryCode = GetCountryCode(bic);

            if (countryCode.Trim().Length < _COUNTRY_CODE_LENGTH || !countryCode.Equals(countryCode.ToUpper()) || !Char.IsLetter(countryCode[0]) || !Char.IsLetter(countryCode[1]))
            {
                throw new BicFormatException("BIC country code must contain upper case letters", BicFormatViolation.COUNTRY_CODE_ONLY_UPPER_CASE_LETTERS);
            }

            if (CountryCode.GetCountryCode(countryCode) == null)
            {
                throw new UnsupportedCountryException("Country code is not supported", countryCode);
            }
        }
Esempio n. 4
0
        private static bool hasValidCountryCode(string bic, out BicFormatViolation validationResult)
        {
            validationResult = BicFormatViolation.NO_VIOLATION;

            string countryCode = GetCountryCode(bic);

            if (countryCode.Trim().Length < _COUNTRY_CODE_LENGTH || !countryCode.Equals(countryCode.ToUpper()) || !Char.IsLetter(countryCode[0]) || !Char.IsLetter(countryCode[1]))
            {
                validationResult = BicFormatViolation.COUNTRY_CODE_ONLY_UPPER_CASE_LETTERS;
            }
            else
            {
                if (CountryCode.GetCountryCode(countryCode) == null)
                {
                    validationResult = BicFormatViolation.COUNTRY_CODE_UNSUPPORTED;
                }
            }

            return(validationResult == BicFormatViolation.NO_VIOLATION);
        }
Esempio n. 5
0
        private static BBanStructure getBbanStructure(string iban)
        {
            string countryCode = GetCountryCode(iban);

            return(getBbanStructure(CountryCode.GetCountryCode(countryCode)));
        }
Esempio n. 6
0
 /// <summary>
 /// Checks whether country is supported.
 /// It is checked by trying to find the country code in defined BBAN structures.
 /// </summary>
 /// <param name="alpha2Code">Alpha2 code for country</param>
 /// <returns>True if country code is supported, othewise false</returns>
 public static bool IsSupportedCountry(string alpha2Code) => (CountryCode.GetCountryCode(alpha2Code) != null) && (Bban.GetStructureForCountry(alpha2Code) != null);
Esempio n. 7
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);
Esempio n. 8
0
 public CountryCodeEntry GetCountryCode() => CountryCode.GetCountryCode(IbanUtils.GetCountryCode(Value));