示例#1
0
        private static bool hasValidBbanEntries(string iban, BBanStructure structure, out IbanFormatViolation validationResult)
        {            
            validationResult = IbanFormatViolation.NO_VIOLATION;

            string bban = GetBBan( iban );
            int bbanOffset = 0;

            foreach (BBanEntry entry in structure.Entries)
            {
                int entryLength = entry.Length;
                string entryValue = bban.Substring( bbanOffset, entryLength );

                bbanOffset += entryLength;
                
                if (!hasValidBbanEntryCharacterType(entry, entryValue, out validationResult))
                {             
                    break;
                }
            }

            return ( validationResult == IbanFormatViolation.NO_VIOLATION );
        }
示例#2
0
        private static bool hasValidBbanLength(string iban, BBanStructure structure, out IbanFormatViolation validationResult)
        {            
            validationResult = IbanFormatViolation.NO_VIOLATION;

            int expectedBbanLength = structure.GetBBanLength();
            string bban = GetBBan( iban );
            int bbanLength = bban.Length;

            if (expectedBbanLength != bbanLength)
            {
                validationResult = IbanFormatViolation.BBAN_LENGTH;
            }

            return ( validationResult == IbanFormatViolation.NO_VIOLATION );
        }
示例#3
0
        private static void validateBbanEntries(string iban, BBanStructure structure)
        {
            string bban = GetBBan( iban );
            int bbanOffset = 0;

            foreach (BBanEntry entry in structure.Entries)
            {
                int entryLength = entry.Length;
                string entryValue = bban.Substring( bbanOffset, entryLength );

                bbanOffset += entryLength;

                validateBbanEntryCharacterType( entry, entryValue );
            }         
        }
示例#4
0
        private static void validateBbanLength(string iban, BBanStructure structure)
        {
            int expectedBbanLength = structure.GetBBanLength();
            string bban = GetBBan( iban );
            int bbanLength = bban.Length;

            if (expectedBbanLength != bbanLength)
            {
                throw new IbanFormatException( $"BBAN '{bban}' length is {bbanLength}, expected is {expectedBbanLength}", 
                                               IbanFormatViolation.BBAN_LENGTH, bbanLength, expectedBbanLength );
            }
        }