Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
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.