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 ); }
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 ); }
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 ); } }
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 ); } }