Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -51,4 +51,16 @@ void testValidator346() {
}
}

/**
* SEDOLs never contain a vowel; each of these carries a correct modulus 10 check digit but a vowel in the
* six-character body, so the check digit alone would otherwise accept it.
*/
@Test
void testVowelsRejected() {
final String[] withVowel = { "B0AKT02", "0EIOU02", "BAEIOU7", "AAAAAA0", };
for (final String code : withVowel) {
assertFalse(routine.isValid(code), "Should fail (contains a vowel): " + code);
}
}

}
Loading