[ 
https://issues.apache.org/jira/browse/VALIDATOR-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996398#comment-14996398
 ] 

Sebb commented on VALIDATOR-379:
--------------------------------

CodeValidator may also use RegexValidator to reformat the input.

So perhaps the problem is really that the isValid() method is misleading.

> 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)

Reply via email to