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

CodeValidator unconditionally trim()s the input string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.6
    • None
    • None

    Description

      The CodeValidator class unconditionally calls String#trim() on the input.

      This seems wrong.

      If the calling code uses the return value from validate to pass to other methods that would be OK, but not all code will do so, especially since this is not documented.

      Code that calls isValid() instead is likely to pass the untrimmed code to a method which is not expecting the additional spaces.

      It's also possible (but rather unlikely) that there are formats which require leading or trailing spaces.

      At the very least this behaviour needs to be documented.

      There probably ought to be a non-trimming version.

      Note that this affects the CreditCardValidator and the ISBNValidator.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: