From ec36c5e2ea83dc51c7f4a759da635d6d0b10316a Mon Sep 17 00:00:00 2001 From: ptorres-prowide <90214684+ptorres-prowide@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:27:17 -0300 Subject: [PATCH 1/2] CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths (#208) * CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths Co-Authored-By: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Sebastian Zubrinic --- CHANGELOG.md | 3 + .../swift/model/field/FieldEnum.java | 3 + .../swift/model/mt/MtSequenceEnum.java | 142 ++++++++++++++++++ .../swift/model/field/FieldEnumTest.java | 44 +++++- .../swift/model/mt/MtSequenceEnumTest.java | 112 ++++++++++++++ 5 files changed, 296 insertions(+), 8 deletions(-) create mode 100644 src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java create mode 100644 src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index af04678b..f0dbe70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Prowide Core - CHANGELOG +#### 9.4.19 - SNAPSHOT + * Added new `MtSequenceEnum` with all the available inner sequences of specific MT schemas + #### 9.4.18 - October 2024 * Added new `FieldEnum` with all the available field names * Code security improvements as per CodeQL recommendations diff --git a/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java b/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java index 21a92201..99ce8044 100644 --- a/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java +++ b/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java @@ -16,11 +16,14 @@ package com.prowidesoftware.swift.model.field; +import com.prowidesoftware.Generated; + /** * Enumeration of fields for SRU 2023 * * @since 9.4.18 */ +@Generated public enum FieldEnum { F11A, diff --git a/src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java b/src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java new file mode 100644 index 00000000..be313b2b --- /dev/null +++ b/src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java @@ -0,0 +1,142 @@ +/* +* Copyright 2006-2024 Prowide +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.prowidesoftware.swift.model.mt; + +import com.prowidesoftware.Generated; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +/** +* Enumeration representing all possible sequence paths for each MT (Message Type) schema. +* Each constant in this enumeration corresponds to a specific MT schema, identified by its +* sequence paths as a comma-separated string (CSV) for SRU 2023. +* +*

For example, the MT508 message type may have sequence paths such as "A", "A/A1", "B", "B/B1", and "C", +* which would be represented as the CSV string "A,A/A1,B,B/B1,C". +* Note that internal loops not clearly identified and named in the standard as a sequence, are excluded. +* +*

For example, the MT801 message contains the "Loop1" and "Loop2" sequences, and this are not included in the sequence paths. +* +* @since 9.4.18 +*/ +@Generated +public enum MtSequenceEnum { + + MT101("A,B"), + MT102("A,B,C"), + MT102_STP("A,B,C"), + MT104("A,B,C"), + MT107("A,B,C"), + MT202COV("A,B"), + MT204("A,B"), + MT205COV("A,B"), + MT300("A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F"), + MT304("A,B,B/B1,B/B2,C,C/C1,C/C1/C1a,D,E"), + MT305("A,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1"), + MT306("A,B,B/B1,B/B2,C,D,E,F,F/F1,G,H,I,J,J/J1,J/J2,K,L,M,M/M1,M/M1/M1a,M/M1/M1a/M1a1"), + MT320("A,B,C,D,E,F,G,H,I"), + MT321("A,A/A1,B,B/B1,B/B2,B/B3,C,C/C1"), + MT330("A,B,C,D,E,F,G,H"), + MT340("A,B,B/B1,B/B2,C,D,E,F,G,G/G1,G/G1/G1a,G/G1/G1a/G1a1"), + MT341("A,B,B/B1,C,D,D/D1,D/D1/D1a,D/D1/D1a/D1a1"), + MT350("A,B,C,D,D/D1,D/D2"), + MT360("A,B,B/B1,C,C/C1,C/C2,C/C3,D,E,E/E1,F,F/F1,F/F2,F/F3,G,H,L,M,N,O,O/O1,O/O1/O1a,O/O1/O1a/O1a1"), + MT361("A,B,B/B1,C,C/C1,C/C2,C/C3,D,E,E/E1,F,F/F1,F/F2,F/F3,G,H,I,J,K,L,M,N,O,P,P/P1,P/P1/P1a,P/P1/P1a/P1a1"), + MT362("A,B,C,D,E"), + MT364("A,B,E,L,M"), + MT365("A,B,E,J,K,L,M"), + MT370("A,A/A1,A/A2,B,B/B1"), + MT380("A,A/A1,B,B/B1,B/B2,C"), + MT381("A,A/A1,B,B/B1,B/B2,C"), + MT416("A,B"), + MT430("A,B"), + MT500("A,A/A1,B,B/B1,B/B2,C,C/C1,C/C2,D,E"), + MT501("A,A/A1,B,B/B1,B/B2,C,C/C1,C/C2,D,E"), + MT502("A,A/A1,B,B/B1,B/B2,B/B3,C,C/C1,C/C2,C/C3,D,E"), + MT503("A,A/A1,A/A2,B,B/B1,C,C/C1,C/C2,C/C3,D"), + MT504("A,A/A1,A/A2,B,B/B1,C,C/C1,C/C1/C1a,C/C1/C1a/C1a1,C/C2,C/C2/C2a,C/C2/C2a/C2a1,C/C3,D,D/D1,E,E/E1,F"), + MT505("A,A/A1,A/A2,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1,B/B2,B/B2/B2a,B/B2/B2a/B2a1,B/B3,C,C/C1,D,D/D1,E"), + MT506("A,A/A1,A/A2,B,B/B1,C,C/C1,C/C2,C/C3,D,D/D1,D/D2,D/D3,E"), + MT507("A,A/A1,A/A2,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1,B/B1/B1b,B/B1/B1b/B1b1,C"), + MT508("A,A/A1,B,B/B1,C"), + MT509("A,A/A1,A/A2,A/A2/A2a,B,B/B1,C"), + MT510("A,A/A1,A/A2,A/A2/A2a,B,C"), + MT513("A,A/A1,B,B/B1,C,C/C1,C/C2,C/C3,D,D/D1,D/D2,D/D3,E,F"), + MT514("A,A/A1,B,B/B1,B/B2,C,C/C1,C/C2,C/C3,D,E"), + MT515("A,A/A1,B,C,C/C1,C/C2,D,D/D1,D/D2,D/D3,E,F"), + MT516("A,B,C"), + MT517("A,A/A1"), + MT518("A,A/A1,B,B/B1,B/B2,C,C/C1,C/C2,C/C3,D,E"), + MT519("A,A/A1,B,B/B1,B/B2,C,C/C1,C/C2,D"), + MT524("A,A/A1,B,B/B1,C"), + MT526("A,B"), + MT527("A,A/A1,A/A2,B,B/B1,C,D,E"), + MT530("A,B,B/B1,C,C/C1,C/C1/C1a"), + MT535("A,A/A1,B,B/B1,B/B1/B1a,B/B1/B1b,B/B1/B1b/B1b1,B/B1/B1c,C"), + MT536("A,A/A1,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1,B/B1/B1a/B1a2,B/B1/B1a/B1a2/B1a2A,C"), + MT537("A,A/A1,B,B/B1,B/B2,B/B2/B2a,B/B2/B2b,B/B2/B2b/B2b1,C,C/C1,C/C2,C/C2/C2a,C/C3,C/C3/C3a,D,D/D1,D/D1/D1a,D/D1/D1a/D1a1,D/D1/D1a/D1a1/D1a1A,D/D1/D1a/D1a1/D1a1A/D1a1A1,D/D1/D1a/D1a1/D1a1B,D/D1/D1a/D1a1/D1a1B/D1a1B1,D/D1/D1a/D1a1/D1a1B/D1a1B1/D1a1B1a,D/D1/D1a/D1a1/D1a1B/D1a1B1/D1a1B1a/D1a1B1a1,E"), + MT538("A,A/A1,B,B/B1,B/B2,B/B2/B2a,B/B2/B2a/B2a1,C"), + MT540("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT541("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT542("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT543("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT544("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT545("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT546("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT547("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT548("A,A/A1,A/A2,A/A2/A2a,B,B/B1,C,C/C1,C/C1/C1a,C/C1/C1a/C1a1,C/C1/C1a/C1a1/C1a1A,C/C1/C1a/C1a1/C1a1A/C1a1A1,C/C1/C1a/C1a1/C1a1B,C/C1/C1a/C1a1/C1a1B/C1a1B1,C/C1/C1a/C1a1/C1a1B/C1a1B1/C1a1B1a,C/C1/C1a/C1a1/C1a1B/C1a1B1/C1a1B1a/C1a1B1a1,D"), + MT549("A,A/A1,B,C,D"), + MT558("A,A/A1,A/A2,A/A2/A2a,A/A3,B,B/B1,C,D,E"), + MT564("A,A/A1,B,B/B1,B/B2,C,D,E,E/E1,E/E1/E1a,E/E2,F"), + MT565("A,A/A1,B,B/B1,B/B2,C,D,E"), + MT566("A,A/A1,B,B/B1,C,D,D/D1,D/D1/D1a,D/D1/D1b,D/D2,D/D2/D2a,D/D2/D2b,E"), + MT567("A,A/A1,A/A2,A/A2/A2a,B,C"), + MT568("A,A/A1,B,B/B1,C"), + MT569("A,A/A1,A/A2,B,C,C/C1,C/C1/C1a,C/C1/C1a/C1a1,C/C1/C1a/C1a1/C1a1A,D"), + MT575("A,A/A1,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1,B/B1/B1a/B1a2,B/B1/B1a/B1a3,B/B1/B1a/B1a4,C,C/C1,C/C2,C/C2/C2a,D"), + MT576("A,A/A1,B,B/B1,B/B2,B/B2/B2a,B/B2/B2b,B/B2/B2c,C"), + MT578("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"), + MT586("A,A/A1,B,B/B1,B/B2,B/B3,B/B4,B/B4/B4a,B/B5,B/B6,B/B6/B6a,B/B6/B6b,C"), + MT600("A,B,C,D,D/D1,D/D1/D1a,D/D1/D1a/D1a1"), + MT601("A,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1"), + MT620("A,B,C,D,E,F,G,G/G1,G/G2,H"), + MT670("A,A/A1,A/A2,B,B/B1,B/B2,C"), + MT671("A,A/A1,B,B/B1,B/B2,C"), + MT760("A,B,C"), + MT767("A,B,C"); + + private final String sequences; + + MtSequenceEnum(String sequences) { + this.sequences = sequences; + } + + /** + * Returns the sequence paths for this MT schema. + * Each sequence path represents a hierarchical structure within the MT schema. + * + * @return A Set of sequence paths. + * + */ + public Set sequences() { + return Arrays.stream(sequences.split(",")) + .collect(Collectors.toSet()); + } + +} diff --git a/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java b/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java index 5a13d43f..babceda4 100644 --- a/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java +++ b/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java @@ -3,20 +3,48 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; class FieldEnu5mTest { - @ParameterizedTest - @CsvSource({"F11A,11A", "F22J,22J", "F44H,44H"}) - void testFieldName(FieldEnum field, String expectedName) { + @Test + void testFieldName_F11A() { + FieldEnum field = FieldEnum.F11A; + String expectedName = "11A"; + assertEquals(expectedName, field.fieldName()); + } + + @Test + void testFieldName_F22J() { + FieldEnum field = FieldEnum.F22J; + String expectedName = "22J"; + assertEquals(expectedName, field.fieldName()); + } + + @Test + void testFieldName_F44H() { + FieldEnum field = FieldEnum.F44H; + String expectedName = "44H"; assertEquals(expectedName, field.fieldName()); } - @ParameterizedTest - @CsvSource({"11A,F11A", "22J,F22J", "44H,F44H"}) - void testFromFieldNameValid(String fieldName, FieldEnum expectedEnum) { + @Test + void testFromFieldNameValid_11A() { + String fieldName = "11A"; + FieldEnum expectedEnum = FieldEnum.F11A; + assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName)); + } + + @Test + void testFromFieldNameValid_22J() { + String fieldName = "22J"; + FieldEnum expectedEnum = FieldEnum.F22J; + assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName)); + } + + @Test + void testFromFieldNameValid_44H() { + String fieldName = "44H"; + FieldEnum expectedEnum = FieldEnum.F44H; assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName)); } diff --git a/src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java b/src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java new file mode 100644 index 00000000..f559a9a7 --- /dev/null +++ b/src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java @@ -0,0 +1,112 @@ +package com.prowidesoftware.swift.model.mt; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import org.junit.jupiter.api.Test; + +/** + * Unit tests for {@link MtSequenceEnum} to validate the sequence definitions + * and format compliance for different SWIFT MT message types. + */ +class MtSequenceEnumTest { + + /** + * Regex pattern for validating SWIFT MT sequence formats. + * Valid examples: + * - "A" (simple sequence) + * - "B/B1" (sequence with numeric suffix) + * - "E/E1/E1a" (nested sequence) + * - "E/E1a/E1a1" (complex nested sequence) + */ + private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$"; + + @Test + void testGetSequences_MT101() { + MtSequenceEnum sequence = MtSequenceEnum.MT101; + Set expectedSequences = new HashSet<>(Arrays.asList("A", "B")); + assertEquals(expectedSequences, sequence.sequences()); + } + + @Test + void testGetSequences_MT102() { + MtSequenceEnum sequence = MtSequenceEnum.MT102; + Set expectedSequences = new HashSet<>(Arrays.asList("A", "B", "C")); + assertEquals(expectedSequences, sequence.sequences()); + } + + @Test + void testGetSequences_MT300() { + MtSequenceEnum sequence = MtSequenceEnum.MT300; + Set expectedSequences = new HashSet<>(Arrays.asList( + "A", "B", "B/B1", "B/B2", "C", "D", "D/D1", "E", "E/E1", "E/E1/E1a", "E/E1/E1a/E1a1", "F")); + assertEquals(expectedSequences, sequence.sequences()); + } + + @Test + void testGetSequences_MT508() { + MtSequenceEnum sequence = MtSequenceEnum.MT508; + Set expectedSequences = new HashSet<>(Arrays.asList("A", "A/A1", "B", "B/B1", "C")); + assertEquals(expectedSequences, sequence.sequences()); + } + + @Test + void testFromFieldNameValid_MT101() { + String fieldName = "MT101"; + MtSequenceEnum expectedEnum = MtSequenceEnum.MT101; + assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName)); + } + + @Test + void testFromFieldNameValid_MT102() { + String fieldName = "MT102"; + MtSequenceEnum expectedEnum = MtSequenceEnum.MT102; + assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName)); + } + + @Test + void testFromFieldNameValid_MT508() { + String fieldName = "MT508"; + MtSequenceEnum expectedEnum = MtSequenceEnum.MT508; + assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName)); + } + + @Test + void testFromFieldNameInvalid() { + assertThrows(NullPointerException.class, () -> MtSequenceEnum.valueOf(null)); + assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("INVALID")); + assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("")); + assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT")); + assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT999999")); + assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MTxxx")); + } + + @Test + void testAllEnumValuesHaveSequences() { + for (MtSequenceEnum seqValue : MtSequenceEnum.values()) { + String enumName = seqValue.name(); + assertNotNull(seqValue.sequences(), String.format("Sequence for enum value '%s' is null", enumName)); + assertFalse( + seqValue.sequences().isEmpty(), + String.format("Sequence for enum value '%s' is empty. Expected at least one sequence.", enumName)); + + // Validate sequence format + Set sequences = seqValue.sequences(); + for (String sequence : sequences) { + assertTrue( + sequence.matches(SEQUENCE_PATTERN), + String.format( + "Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN)); + } + + // Check for duplicates + Set uniqueSequences = new HashSet<>(sequences); + assertEquals( + sequences.size(), + uniqueSequences.size(), + String.format("Sequences in %s contain duplicates: %s", enumName, sequences)); + } + } +} From 82ec241cd38a689b132a97d0b93cb5c6f62ff79e Mon Sep 17 00:00:00 2001 From: ptorres-prowide <90214684+ptorres-prowide@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:44:18 -0300 Subject: [PATCH 2/2] CU-86b2gwt48_PW-2040--IBAN-validation-problem (#212) * CU-86b2gwt48_PW-2040--IBAN-validation-problem * change log and info file --------- Co-authored-by: Sebastian Zubrinic --- CHANGELOG.md | 1 + .../swift/model/IbanValidationResult.java | 2 +- .../swift/model/IbanValidationUtils.java | 2 +- .../resources/BbanStructureValidations.json | 736 ++++++++++++------ .../BbanStructureValidations.json.info | 1 + .../swift/constraints/IbanValidatorTest.java | 6 +- .../prowidesoftware/swift/model/IBANTest.java | 93 ++- 7 files changed, 607 insertions(+), 234 deletions(-) create mode 100644 src/main/resources/BbanStructureValidations.json.info diff --git a/CHANGELOG.md b/CHANGELOG.md index f0dbe70d..bfed8343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Prowide Core - CHANGELOG #### 9.4.19 - SNAPSHOT + * (PW-2040) Updated the BBAN validation data file to the IBAN REGISTRY Jul 2024 release * Added new `MtSequenceEnum` with all the available inner sequences of specific MT schemas #### 9.4.18 - October 2024 diff --git a/src/main/java/com/prowidesoftware/swift/model/IbanValidationResult.java b/src/main/java/com/prowidesoftware/swift/model/IbanValidationResult.java index 34c9d92d..47568d7d 100644 --- a/src/main/java/com/prowidesoftware/swift/model/IbanValidationResult.java +++ b/src/main/java/com/prowidesoftware/swift/model/IbanValidationResult.java @@ -42,7 +42,7 @@ public enum IbanValidationResult { INVALID_CHARACTERS("Invalid character '${found}' found"), MISSING_CHECK_DIGITS("Missing check digits"), INVALID_CHECK_DIGITS_FORMAT("Expected 2 check digits and found ${found}"), - IVALID_CHECK_DIGITS("The expected computed check digit is ${expectedCheckDigit} and ${found} was found"), + INVALID_CHECK_DIGITS("The expected computed check digit is ${expectedCheckDigit} and ${found} was found"), MISSING_BBAN("Missing custom account number (BBAN)"), BBAN_MAX_LENGTH( diff --git a/src/main/java/com/prowidesoftware/swift/model/IbanValidationUtils.java b/src/main/java/com/prowidesoftware/swift/model/IbanValidationUtils.java index 5d67ad43..5e775b0c 100644 --- a/src/main/java/com/prowidesoftware/swift/model/IbanValidationUtils.java +++ b/src/main/java/com/prowidesoftware/swift/model/IbanValidationUtils.java @@ -214,7 +214,7 @@ static IbanValidationResult validateCheckDigit(final String iban) { if (calculateMod(iban) != 1) { final String checkDigit = IBAN.getCheckDigits(iban); final String expectedCheckDigit = calculateCheckDigit(iban); - IbanValidationResult result = IbanValidationResult.IVALID_CHECK_DIGITS; + IbanValidationResult result = IbanValidationResult.INVALID_CHECK_DIGITS; result.setExpectedCheckDigit(expectedCheckDigit); result.setFound(checkDigit); return result; diff --git a/src/main/resources/BbanStructureValidations.json b/src/main/resources/BbanStructureValidations.json index 8dc55754..15ca5dc9 100644 --- a/src/main/resources/BbanStructureValidations.json +++ b/src/main/resources/BbanStructureValidations.json @@ -1,10 +1,10 @@ [ { - "country_code": "AL", + "country_code": "AD", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 4, "character_type": "n" }, { @@ -13,33 +13,38 @@ "character_type": "n" }, { - "entry_type": "national_check_digit", - "length": 16, + "entry_type": "account_number", + "length": 12, "character_type": "c" + } + ] + }, + { + "country_code": "AE", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 3, + "character_type": "n" }, { "entry_type": "account_number", - "length": 1, + "length": 16, "character_type": "n" } ] }, { - "country_code": "AD", + "country_code": "AL", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "n" - }, - { - "entry_type": "branch_code", - "length": 4, + "length": 8, "character_type": "n" }, { "entry_type": "account_number", - "length": 12, + "length": 16, "character_type": "c" } ] @@ -75,16 +80,26 @@ ] }, { - "country_code": "BH", + "country_code": "BA", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "a" + "length": 3, + "character_type": "n" + }, + { + "entry_type": "branch_code", + "length": 3, + "character_type": "n" }, { "entry_type": "account_number", - "length": 14, + "length": 8, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 2, "character_type": "n" } ] @@ -110,21 +125,61 @@ ] }, { - "country_code": "BA", + "country_code": "BG", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, - "character_type": "n" + "length": 4, + "character_type": "a" }, { "entry_type": "branch_code", - "length": 3, + "length": 4, + "character_type": "n" + }, + { + "entry_type": "account_type", + "length": 2, "character_type": "n" }, { "entry_type": "account_number", "length": 8, + "character_type": "c" + } + ] + }, + { + "country_code": "BH", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" + }, + { + "entry_type": "account_number", + "length": 14, + "character_type": "n" + } + ] + }, + { + "country_code": "BI", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 5, + "character_type": "n" + }, + { + "entry_type": "branch_code", + "length": 5, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 11, "character_type": "n" }, { @@ -165,26 +220,31 @@ ] }, { - "country_code": "BG", + "country_code": "BY", "validation_rules": [ { "entry_type": "bank_code", "length": 4, - "character_type": "a" + "character_type": "c" }, { - "entry_type": "branch_code", - "length": 4, - "character_type": "n" - }, + "entry_type": "account_number", + "length": 20, + "character_type": "c" + } + ] + }, + { + "country_code": "CH", + "validation_rules": [ { - "entry_type": "account_type", - "length": 2, + "entry_type": "bank_code", + "length": 5, "character_type": "n" }, { "entry_type": "account_number", - "length": 8, + "length": 12, "character_type": "c" } ] @@ -194,7 +254,7 @@ "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 4, "character_type": "n" }, { @@ -205,46 +265,46 @@ ] }, { - "country_code": "DE", + "country_code": "CY", "validation_rules": [ { "entry_type": "bank_code", - "length": 8, + "length": 3, "character_type": "n" }, { - "entry_type": "account_number", - "length": 10, + "entry_type": "branch_code", + "length": 5, "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 16, + "character_type": "c" } ] }, { - "country_code": "EG", + "country_code": "CZ", "validation_rules": [ { "entry_type": "bank_code", "length": 4, "character_type": "n" }, - { - "entry_type": "branch_code", - "length": 4, - "character_type": "n" - }, { "entry_type": "account_number", - "length": 17, + "length": 16, "character_type": "n" } ] }, { - "country_code": "HR", + "country_code": "DE", "validation_rules": [ { "entry_type": "bank_code", - "length": 7, + "length": 8, "character_type": "n" }, { @@ -255,11 +315,11 @@ ] }, { - "country_code": "CY", + "country_code": "DJ", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 5, "character_type": "n" }, { @@ -269,22 +329,12 @@ }, { "entry_type": "account_number", - "length": 16, + "length": 11, "character_type": "c" - } - ] - }, - { - "country_code": "CZ", - "validation_rules": [ - { - "entry_type": "bank_code", - "length": 4, - "character_type": "n" }, { - "entry_type": "account_number", - "length": 16, + "entry_type": "national_check_digit", + "length": 2, "character_type": "n" } ] @@ -299,7 +349,12 @@ }, { "entry_type": "account_number", - "length": 10, + "length": 9, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 1, "character_type": "n" } ] @@ -345,21 +400,46 @@ ] }, { - "country_code": "FO", + "country_code": "EG", "validation_rules": [ { "entry_type": "bank_code", "length": 4, "character_type": "n" }, + { + "entry_type": "branch_code", + "length": 4, + "character_type": "n" + }, { "entry_type": "account_number", - "length": 9, + "length": 17, + "character_type": "n" + } + ] + }, + { + "country_code": "ES", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "n" + }, + { + "entry_type": "branch_code", + "length": 4, "character_type": "n" }, { "entry_type": "national_check_digit", - "length": 1, + "length": 2, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 10, "character_type": "n" } ] @@ -369,12 +449,42 @@ "validation_rules": [ { "entry_type": "bank_code", - "length": 6, + "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 7, + "length": 11, + "character_type": "n" + } + ] + }, + { + "country_code": "FK", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 2, + "character_type": "a" + }, + { + "entry_type": "account_number", + "length": 12, + "character_type": "n" + } + ] + }, + { + "country_code": "FO", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 9, "character_type": "n" }, { @@ -409,6 +519,26 @@ } ] }, + { + "country_code": "GB", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" + }, + { + "entry_type": "branch_code", + "length": 6, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 8, + "character_type": "n" + } + ] + }, { "country_code": "GE", "validation_rules": [ @@ -490,51 +620,41 @@ ] }, { - "country_code": "HU", + "country_code": "HR", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, - "character_type": "n" - }, - { - "entry_type": "branch_code", - "length": 4, + "length": 7, "character_type": "n" }, { "entry_type": "account_number", - "length": 16, - "character_type": "n" - }, - { - "entry_type": "national_check_digit", - "length": 1, + "length": 10, "character_type": "n" } ] }, { - "country_code": "IS", + "country_code": "HU", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, + "length": 3, "character_type": "n" }, { "entry_type": "branch_code", - "length": 2, + "length": 4, "character_type": "n" }, { "entry_type": "account_number", - "length": 6, + "length": 16, "character_type": "n" }, { - "entry_type": "identification_number", - "length": 10, + "entry_type": "national_check_digit", + "length": 1, "character_type": "n" } ] @@ -580,16 +700,46 @@ ] }, { - "country_code": "IR", + "country_code": "IQ", "validation_rules": [ { "entry_type": "bank_code", + "length": 4, + "character_type": "a" + }, + { + "entry_type": "branch_code", "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 19, + "length": 12, + "character_type": "n" + } + ] + }, + { + "country_code": "IS", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "n" + }, + { + "entry_type": "branch_code", + "length": 2, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 6, + "character_type": "n" + }, + { + "entry_type": "identification_number", + "length": 10, "character_type": "n" } ] @@ -640,61 +790,61 @@ ] }, { - "country_code": "KZ", + "country_code": "KW", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, - "character_type": "n" + "length": 4, + "character_type": "a" }, { "entry_type": "account_number", - "length": 13, + "length": 22, "character_type": "c" } ] }, { - "country_code": "KW", + "country_code": "KZ", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "a" + "length": 3, + "character_type": "n" }, { "entry_type": "account_number", - "length": 22, + "length": 13, "character_type": "c" } ] }, { - "country_code": "LV", + "country_code": "LB", "validation_rules": [ { "entry_type": "bank_code", "length": 4, - "character_type": "a" + "character_type": "n" }, { "entry_type": "account_number", - "length": 13, + "length": 20, "character_type": "c" } ] }, { - "country_code": "LB", + "country_code": "LC", "validation_rules": [ { "entry_type": "bank_code", "length": 4, - "character_type": "n" + "character_type": "a" }, { "entry_type": "account_number", - "length": 20, + "length": 24, "character_type": "c" } ] @@ -745,52 +895,47 @@ ] }, { - "country_code": "MK", + "country_code": "LV", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, - "character_type": "n" + "length": 4, + "character_type": "a" }, { "entry_type": "account_number", - "length": 10, + "length": 13, "character_type": "c" - }, - { - "entry_type": "national_check_digit", - "length": 2, - "character_type": "n" } ] }, { - "country_code": "MT", + "country_code": "LY", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "a" + "length": 3, + "character_type": "n" }, { "entry_type": "branch_code", - "length": 5, + "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 18, - "character_type": "c" + "length": 15, + "character_type": "n" } ] }, { - "country_code": "MR", + "country_code": "MC", "validation_rules": [ { "entry_type": "bank_code", "length": 5, - "character_type": "a" + "character_type": "n" }, { "entry_type": "branch_code", @@ -805,47 +950,82 @@ { "entry_type": "national_check_digit", "length": 2, - "character_type": "c" + "character_type": "n" } ] }, { - "country_code": "MU", + "country_code": "MD", "validation_rules": [ { "entry_type": "bank_code", - "length": 6, + "length": 2, "character_type": "c" }, { - "entry_type": "branch_code", + "entry_type": "account_number", + "length": 18, + "character_type": "c" + } + ] + }, + { + "country_code": "ME", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 3, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 13, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", "length": 2, "character_type": "n" + } + ] + }, + { + "country_code": "MK", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 3, + "character_type": "n" }, { "entry_type": "account_number", - "length": 18, + "length": 10, "character_type": "c" + }, + { + "entry_type": "national_check_digit", + "length": 2, + "character_type": "n" } ] }, { - "country_code": "MD", + "country_code": "MN", "validation_rules": [ { "entry_type": "bank_code", - "length": 2, - "character_type": "c" + "length": 4, + "character_type": "n" }, { "entry_type": "account_number", - "length": 18, - "character_type": "c" + "length": 12, + "character_type": "n" } ] }, { - "country_code": "MC", + "country_code": "MR", "validation_rules": [ { "entry_type": "bank_code", @@ -860,7 +1040,7 @@ { "entry_type": "account_number", "length": 11, - "character_type": "c" + "character_type": "n" }, { "entry_type": "national_check_digit", @@ -870,22 +1050,57 @@ ] }, { - "country_code": "ME", + "country_code": "MT", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 4, + "character_type": "a" + }, + { + "entry_type": "branch_code", + "length": 5, "character_type": "n" }, { "entry_type": "account_number", - "length": 13, - "character_type": "n" + "length": 18, + "character_type": "c" + } + ] + }, + { + "country_code": "MU", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 6, + "character_type": "c" }, { - "entry_type": "national_check_digit", + "entry_type": "branch_code", "length": 2, "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 18, + "character_type": "c" + } + ] + }, + { + "country_code": "NI", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" + }, + { + "entry_type": "account_number", + "length": 20, + "character_type": "n" } ] }, @@ -925,22 +1140,22 @@ ] }, { - "country_code": "PK", + "country_code": "OM", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "c" + "length": 3, + "character_type": "n" }, { "entry_type": "account_number", "length": 16, - "character_type": "n" + "character_type": "c" } ] }, { - "country_code": "PS", + "country_code": "PK", "validation_rules": [ { "entry_type": "bank_code", @@ -949,7 +1164,7 @@ }, { "entry_type": "account_number", - "length": 21, + "length": 16, "character_type": "c" } ] @@ -957,25 +1172,30 @@ { "country_code": "PL", "validation_rules": [ - { - "entry_type": "bank_code", - "length": 3, - "character_type": "n" - }, { "entry_type": "branch_code", - "length": 4, + "length": 8, "character_type": "n" }, { - "entry_type": "national_check_digit", - "length": 1, + "entry_type": "account_number", + "length": 16, "character_type": "n" + } + ] + }, + { + "country_code": "PS", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" }, { "entry_type": "account_number", - "length": 16, - "character_type": "n" + "length": 21, + "character_type": "c" } ] }, @@ -1005,7 +1225,7 @@ ] }, { - "country_code": "RO", + "country_code": "QA", "validation_rules": [ { "entry_type": "bank_code", @@ -1014,13 +1234,13 @@ }, { "entry_type": "account_number", - "length": 16, + "length": 21, "character_type": "c" } ] }, { - "country_code": "QA", + "country_code": "RO", "validation_rules": [ { "entry_type": "bank_code", @@ -1029,22 +1249,37 @@ }, { "entry_type": "account_number", - "length": 21, + "length": 16, "character_type": "c" } ] }, { - "country_code": "SM", + "country_code": "RS", "validation_rules": [ { - "entry_type": "national_check_digit", - "length": 1, - "character_type": "a" + "entry_type": "bank_code", + "length": 3, + "character_type": "n" }, + { + "entry_type": "account_number", + "length": 13, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 2, + "character_type": "n" + } + ] + }, + { + "country_code": "RU", + "validation_rules": [ { "entry_type": "bank_code", - "length": 5, + "length": 9, "character_type": "n" }, { @@ -1054,7 +1289,7 @@ }, { "entry_type": "account_number", - "length": 12, + "length": 15, "character_type": "c" } ] @@ -1075,113 +1310,118 @@ ] }, { - "country_code": "RS", + "country_code": "SC", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 6, + "character_type": "c" + }, + { + "entry_type": "branch_code", + "length": 2, "character_type": "n" }, { "entry_type": "account_number", - "length": 13, + "length": 16, "character_type": "n" }, { - "entry_type": "national_check_digit", - "length": 2, - "character_type": "n" + "entry_type": "currency", + "length": 3, + "character_type": "a" } ] }, { - "country_code": "SK", + "country_code": "SD", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, + "length": 2, "character_type": "n" }, { "entry_type": "account_number", - "length": 16, + "length": 12, "character_type": "n" } ] }, { - "country_code": "SI", + "country_code": "SE", "validation_rules": [ { "entry_type": "bank_code", - "length": 2, - "character_type": "n" - }, - { - "entry_type": "branch_code", "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 8, + "length": 16, "character_type": "n" }, { "entry_type": "national_check_digit", - "length": 2, + "length": 1, "character_type": "n" } ] }, { - "country_code": "ES", + "country_code": "SI", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, + "length": 5, "character_type": "n" }, { - "entry_type": "branch_code", - "length": 4, + "entry_type": "account_number", + "length": 8, "character_type": "n" }, { "entry_type": "national_check_digit", "length": 2, "character_type": "n" - }, - { - "entry_type": "account_number", - "length": 10, - "character_type": "n" } ] }, { - "country_code": "SE", + "country_code": "SK", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 4, "character_type": "n" }, { "entry_type": "account_number", - "length": 17, + "length": 16, "character_type": "n" } ] }, { - "country_code": "CH", + "country_code": "SM", "validation_rules": [ + { + "entry_type": "national_check_digit", + "length": 1, + "character_type": "a" + }, { "entry_type": "bank_code", "length": 5, "character_type": "n" }, + { + "entry_type": "branch_code", + "length": 5, + "character_type": "n" + }, { "entry_type": "account_number", "length": 12, @@ -1190,11 +1430,11 @@ ] }, { - "country_code": "TN", + "country_code": "SO", "validation_rules": [ { "entry_type": "bank_code", - "length": 2, + "length": 4, "character_type": "n" }, { @@ -1204,72 +1444,107 @@ }, { "entry_type": "account_number", - "length": 15, - "character_type": "c" + "length": 12, + "character_type": "n" } ] }, { - "country_code": "TR", + "country_code": "ST", "validation_rules": [ { "entry_type": "bank_code", - "length": 5, + "length": 4, + "character_type": "n" + }, + { + "entry_type": "branch_code", + "length": 4, + "character_type": "n" + }, + { + "entry_type": "account_number", + "length": 11, "character_type": "n" }, { "entry_type": "national_check_digit", - "length": 1, - "character_type": "c" + "length": 2, + "character_type": "n" + } + ] + }, + { + "country_code": "SV", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" }, { "entry_type": "account_number", - "length": 16, - "character_type": "c" + "length": 20, + "character_type": "n" } ] }, { - "country_code": "UA", + "country_code": "TL", "validation_rules": [ { "entry_type": "bank_code", - "length": 6, + "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 19, + "length": 14, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 2, "character_type": "n" } ] }, { - "country_code": "GB", + "country_code": "TN", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "a" + "length": 2, + "character_type": "n" }, { "entry_type": "branch_code", - "length": 6, + "length": 3, "character_type": "n" }, { "entry_type": "account_number", - "length": 8, + "length": 13, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 2, "character_type": "n" } ] }, { - "country_code": "AE", + "country_code": "TR", "validation_rules": [ { "entry_type": "bank_code", - "length": 3, + "length": 5, + "character_type": "n" + }, + { + "entry_type": "national_check_digit", + "length": 1, "character_type": "n" }, { @@ -1280,22 +1555,22 @@ ] }, { - "country_code": "VG", + "country_code": "UA", "validation_rules": [ { "entry_type": "bank_code", - "length": 4, - "character_type": "c" + "length": 6, + "character_type": "n" }, { "entry_type": "account_number", - "length": 16, - "character_type": "n" + "length": 19, + "character_type": "c" } ] }, { - "country_code": "TL", + "country_code": "VA", "validation_rules": [ { "entry_type": "bank_code", @@ -1304,12 +1579,22 @@ }, { "entry_type": "account_number", - "length": 14, + "length": 15, "character_type": "n" + } + ] + }, + { + "country_code": "VG", + "validation_rules": [ + { + "entry_type": "bank_code", + "length": 4, + "character_type": "a" }, { - "entry_type": "national_check_digit", - "length": 2, + "entry_type": "account_number", + "length": 16, "character_type": "n" } ] @@ -1324,7 +1609,7 @@ }, { "entry_type": "branch_code", - "length": 12, + "length": 2, "character_type": "n" }, { @@ -1340,7 +1625,7 @@ ] }, { - "country_code": "SC", + "country_code": "YE", "validation_rules": [ { "entry_type": "bank_code", @@ -1354,13 +1639,8 @@ }, { "entry_type": "account_number", - "length": 16, - "character_type": "n" - }, - { - "entry_type": "currency", - "length": 3, - "character_type": "a" + "length": 18, + "character_type": "c" } ] } diff --git a/src/main/resources/BbanStructureValidations.json.info b/src/main/resources/BbanStructureValidations.json.info new file mode 100644 index 00000000..4b63414d --- /dev/null +++ b/src/main/resources/BbanStructureValidations.json.info @@ -0,0 +1 @@ +Last update of the JSON data structure: IBAN REGISTRY ISO 13616 Release 98 – Jul 2024 \ No newline at end of file diff --git a/src/test/java/com/prowidesoftware/swift/constraints/IbanValidatorTest.java b/src/test/java/com/prowidesoftware/swift/constraints/IbanValidatorTest.java index 861e51b3..dc5304ed 100644 --- a/src/test/java/com/prowidesoftware/swift/constraints/IbanValidatorTest.java +++ b/src/test/java/com/prowidesoftware/swift/constraints/IbanValidatorTest.java @@ -118,12 +118,12 @@ public void testBbanMaxLengthExceeded() { @Test public void testMissingBbanConfiguration() { - String missingBbanConfigIban = "FK64123456789"; + String missingBbanConfigIban = "AX64123456789"; assertEquals(IbanValidationResult.MISSING_BBAN_CONFIGURATION, new IBAN(missingBbanConfigIban).validate()); assertFalse(validator.isValid(missingBbanConfigIban, context)); assertTrue(context.isViolationOccurred()); assertEquals( - "Missing custom account number (BBAN) configuration for country FK", context.getViolationMessage()); + "Missing custom account number (BBAN) configuration for country AX", context.getViolationMessage()); } @Test @@ -181,7 +181,7 @@ public void testInvalidCharacters() { @Test public void testInvalidCheckDigits() { String invalidCheckDigitsIban = "ES0012345678901234567890"; // Invalid computed check digits - assertEquals(IbanValidationResult.IVALID_CHECK_DIGITS, new IBAN(invalidCheckDigitsIban).validate()); + assertEquals(IbanValidationResult.INVALID_CHECK_DIGITS, new IBAN(invalidCheckDigitsIban).validate()); assertFalse(validator.isValid(invalidCheckDigitsIban, context)); assertTrue(context.isViolationOccurred()); assertEquals("The expected computed check digit is 98 and 00 was found", context.getViolationMessage()); diff --git a/src/test/java/com/prowidesoftware/swift/model/IBANTest.java b/src/test/java/com/prowidesoftware/swift/model/IBANTest.java index faa407ad..59b57298 100644 --- a/src/test/java/com/prowidesoftware/swift/model/IBANTest.java +++ b/src/test/java/com/prowidesoftware/swift/model/IBANTest.java @@ -262,12 +262,103 @@ public void testSomeValidCodes() { assertIbanOk(" GB06 LOYD 3097 5104 5702 05."); assertIbanOk("GB26BOFS80200643721002"); assertIbanOk("EG389004000100300074201200001"); + assertIbanOk("IL620108000000099999999"); + + assertIbanOk("AD1200012030200359100100"); // Andorra + assertIbanOk("AE070331234567890123456"); // United Arab Emirates + assertIbanOk("AL7620511021812537CLPRCFUSDP"); // Albania + assertIbanOk("AT611904300234573201"); // Austria + assertIbanOk("AZ21NABZ00000000137010001944"); // Azerbaijan + assertIbanOk("BA391290079401028494"); // Bosnia and Herzegovina + assertIbanOk("BE68539007547034"); // Belgium + assertIbanOk("BG80BNBG96611020345678"); // Bulgaria + assertIbanOk("BH67BMAG00001299123456"); // Bahrain + assertIbanOk("BI4210000100010000332045181"); // Burundi + assertIbanOk("BR1800360305000010009795493C1"); // Brazil + assertIbanOk("BY13NBRB3600900000002Z00AB00"); // Republic of Belarus + assertIbanOk("CH9300762011623852957"); // Switzerland + assertIbanOk("CR05015202001026284066"); // Costa Rica + assertIbanOk("CY17002001280000001200527600"); // Cyprus + assertIbanOk("CZ6508000000192000145399"); // Czech Republic + assertIbanOk("DE89370400440532013000"); // Germany + assertIbanOk("DJ2100010000000154000100186"); // Djibouti + assertIbanOk("DK5000400440116243"); // Denmark + assertIbanOk("DO28BAGR00000001212453611324"); // Dominican Republic + assertIbanOk("EE382200221020145685"); // Estonia + assertIbanOk("EG380019000500000000263180002"); // Egypt + assertIbanOk("ES9121000418450200051332"); // Spain + assertIbanOk("FI2112345600000785"); // Finland + assertIbanOk("FK88SC123456789012"); // Falkland Islands + assertIbanOk("FO6264600001631634"); // Faroe Islands + assertIbanOk("FR1420041010050500013M02606"); // France + assertIbanOk("GB29NWBK60161331926819"); // United Kingdom + assertIbanOk("GE29NB0000000101904917"); // Georgia + assertIbanOk("GI75NWBK000000007099453"); // Gibraltar + assertIbanOk("GL8964710001000206"); // Greenland + assertIbanOk("GR1601101250000000012300695"); // Greece + assertIbanOk("GT82TRAJ01020000001210029690"); // Guatemala + assertIbanOk("HR1210010051863000160"); // Croatia + assertIbanOk("HU42117730161111101800000000"); // Hungary + assertIbanOk("IE29AIBK93115212345678"); // Ireland + assertIbanOk("IL620108000000099999999"); // Israel + assertIbanOk("IQ98NBIQ850123456789012"); // Iraq + assertIbanOk("IS140159260076545510730339"); // Iceland + assertIbanOk("IT60X0542811101000000123456"); // Italy + assertIbanOk("JO94CBJO0010000000000131000302"); // Jordan + assertIbanOk("KW81CBKU0000000000001234560101"); // Kuwait + assertIbanOk("KZ86125KZT5004100100"); // Kazakhstan + assertIbanOk("LB62099900000001001901229114"); // Lebanon + assertIbanOk("LC55HEMM000100010012001200023015"); // Saint Lucia + assertIbanOk("LI21088100002324013AA"); // Liechtenstein + assertIbanOk("LT121000011101001000"); // Lithuania + assertIbanOk("LU280019400644750000"); // Luxembourg + assertIbanOk("LV80BANK0000435195001"); // Latvia + assertIbanOk("LY83002048000020100120361"); // Libya + assertIbanOk("MC5811222000010123456789030"); // Monaco + assertIbanOk("MD24AG000225100013104168"); // Moldova + assertIbanOk("ME25505000012345678951"); // Montenegro + assertIbanOk("MK07200002785123453"); // North Macedonia + assertIbanOk("MR1300020001010000123456753"); // Mauritania + assertIbanOk("MT84MALT011000012345MTLCAST001S"); // Malta + assertIbanOk("MU17BOMM0101101030300200000MUR"); // Mauritius + assertIbanOk("NL91ABNA0417164300"); // Netherlands + assertIbanOk("NO9386011117947"); // Norway + assertIbanOk("PK36SCBL0000001123456702"); // Pakistan + assertIbanOk("PL61109010140000071219812874"); // Poland + assertIbanOk("PS92PALS000000000400123456702"); // Palestine, State of + assertIbanOk("PT50000201231234567890154"); // Portugal + assertIbanOk("QA58DOHB00001234567890ABCDEFG"); // Qatar + assertIbanOk("RO49AAAA1B31007593840000"); // Romania + assertIbanOk("RS35260005601001611379"); // Serbia + assertIbanOk("SA0380000000608010167519"); // Saudi Arabia + assertIbanOk("SC18SSCB11010000000000001497USD"); // Seychelles + assertIbanOk("SE4550000000058398257466"); // Sweden + assertIbanOk("SI56263300012039086"); // Slovenia + assertIbanOk("SK3112000000198742637541"); // Slovakia + assertIbanOk("SM86U0322509800000000270100"); // San Marino + assertIbanOk("ST32000200010192194210112"); // Sao Tome and Principe + assertIbanOk("SV62CENR00000000000000700025"); // El Salvador + assertIbanOk("TL380080012345678910157"); // Timor-Leste + assertIbanOk("TN5914207207100707129648"); // Tunisia + assertIbanOk("TR330006100519786457841326"); // Turkey + assertIbanOk("UA213223130000026007233566001"); // Ukraine + assertIbanOk("VG96VPVG0000012345678901"); // Virgin Islands + assertIbanOk("XK051212012345678906"); // Kosovo + assertIbanOk("YE15CBYE0001018861234567891234"); // Yemen + + assertIbanOk("IQ24TRIQ994005007249002"); + assertIbanOk("IQ24TRIQ994005007249002"); + assertIbanOk("LY57009001000000000003093"); + assertIbanOk("AL7620511021812537CLPRCFUSDP"); + assertIbanOk("AL9220512046016756CLPRCFEURR"); + assertIbanOk("BY41PJCB30120730451000000840"); + assertIbanOk("BY98PJCB30120730451000000978"); } private void assertIbanOk(String string) { IBAN iban = new IBAN(string); IbanValidationResult result = iban.validate(); // System.out.println(result.message()); - assertEquals(result, IbanValidationResult.OK); + assertEquals(IbanValidationResult.OK, result); } }