Sebb created VALIDATOR-379:
------------------------------
Summary: CodeValidator unconditionally trim()s the input string
Key: VALIDATOR-379
URL: https://issues.apache.org/jira/browse/VALIDATOR-379
Project: Commons Validator
Issue Type: Bug
Reporter: Sebb
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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)