You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/07/04 11:55:55 UTC
(commons-validator) branch master updated: Reject vowels in SedolCheckDigit (#415).
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new dff72662 Reject vowels in SedolCheckDigit (#415).
dff72662 is described below
commit dff72662052af44d536bdba5c2eae064273e16a1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 4 07:55:48 2026 -0400
Reject vowels in SedolCheckDigit (#415).
- Merge range check
- Sort members
---
src/changes/changes.xml | 1 +
.../routines/checkdigit/SedolCheckDigit.java | 19 ++++++++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 93f9e1d4..10db7393 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -97,6 +97,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Compare exact values in DoubleValidator range checks (#410).</action>
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Handle non-finite bounds in BigIntegerValidator range checks (#414).</action>
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Fix swapped constant maps in Form.process for extended forms (#413).</action>
+ <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Reject vowels in SedolCheckDigit (#415).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use CheckDigitException.CheckDigitException(String, Object...) (#389).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ValidatorException.ValidatorException(Throwable). Call sites that previously called new ValidatorException(Throwable#getMessage()) now preserve that exception (#390).</action>
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
index 499f1bb7..2054fbe3 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
@@ -72,6 +72,10 @@ public final class SedolCheckDigit extends ModulusCheckDigit {
return super.calculateModulus(code, includesCheckDigit);
}
+ private boolean isVowel(final char character) {
+ return "AEIOU".indexOf(Character.toUpperCase(character)) >= 0;
+ }
+
/**
* Convert a character at a specified position to an integer value.
*
@@ -79,27 +83,20 @@ public final class SedolCheckDigit extends ModulusCheckDigit {
* @param leftPos The position of the character in the code, counting from left to right.
* @param rightPos The position of the character in the code, counting from right to left.
* @return The integer value of the character.
- * @throws CheckDigitException if character is not alphanumeric.
+ * @throws CheckDigitException if character is not alphanumeric or a vowel.
*/
@Override
protected int toInt(final char character, final int leftPos, final int rightPos) throws CheckDigitException {
final int charValue = Character.getNumericValue(character);
// the check digit is only allowed to reach 9
final int charValueMax = rightPos == 1 ? 9 : MAX_ALPHANUMERIC_VALUE; // CHECKSTYLE IGNORE MagicNumber
- 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);
+ // The SEDOL alphabet excludes the vowels A, E, I, O and U, and treats Y as a consonant.
+ if (charValue > charValueMax || !isAsciiAlphaNum(character) || isVowel(character)) {
+ throw new CheckDigitException("Invalid Character[%d,%d] = '%d' out of range 0 to %d, exclusing vowels.", leftPos, rightPos, charValue, charValueMax);
}
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.
*