Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ protected int toInt(final char character, final int leftPos, final int rightPos)
if (charValue > charValueMax || !isAsciiAlphaNum(character)) {
throw new CheckDigitException("Invalid Character[%d,%d] = '%d' out of range 0 to %d", leftPos, rightPos, charValue, charValueMax);
}
// The SEDOL alphabet omits the vowels A, E, I, O and U, so a code containing one is not a SEDOL.
if (isVowel(character)) {
throw new CheckDigitException("Invalid Character[%d,%d] = '%c' - vowels are not used in a SEDOL", leftPos, rightPos, character);
}
return charValue;
}

private boolean isVowel(final char character) {
return "AEIOU".indexOf(Character.toUpperCase(character)) >= 0;
}

/**
* Calculates the <em>weighted</em> value of a character in the code at a specified position.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

/**
* ISIN Check Digit Test.
Expand Down Expand Up @@ -51,4 +53,15 @@ void testValidator346() {
}
}

/**
* SEDOLs never contain a vowel, yet each of these codes carries a correct modulus 10 check digit with a vowel in
* its body, so without the vowel exclusion the check digit alone would accept it. The first five isolate A, E, I,
* O and U individually; the remainder combine several.
*/
@ParameterizedTest
@ValueSource(strings = { "A000000", "E000006", "I000002", "O000006", "U000000", "B0AKT02", "0EIOU02", "BAEIOU7", "AAAAAA0" })
void testVowelsRejected(final String code) {
assertFalse(routine.isValid(code), "Should fail (contains a vowel): " + code);
}

}
Loading