Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-336

CUSIPCheckDigit thinks invalid CUSIP is valid

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4.0 Release
    • 1.4.1 Release
    • Routines
    • None

    Description

      When testing if a specific CUSIP is valid using org.apache.commons.validator.routines.checkdigit.CUSIPCheckDigit.CUSIP_CHECK_DIGIT.isValid, a call to this returns true when it should return false. A specific example is with the following invalid CUSIP: DUS0421CW.

      What seems to be happening is when toInt is called on W it turns it to an int value and then sends it to weightedValue. This is fine for the first 8 characters of a CUSIP, but not the check digit. The expected result should be to return false because the check digit is a letter (on a CUSIP a check digit must be 0-9).

      With the current implementation, I believe each CUSIP can have up to 4 valid check digits.

      A test is attached.

      Attachments

        1. cusip.patch
          2 kB
          Sebb
        2. VALIDATOR-336.patch
          2 kB
          Benedikt Ritter
        3. CusipValidatorTest_v2.java
          0.9 kB
          Peter Lindberg
        4. CUSIPCheckDigit.java.patch
          1 kB
          Peter Lindberg
        5. CusipValidatorTest.java
          2 kB
          Josh Meyer

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            britter Benedikt Ritter
            jjmeyer0 Josh Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment