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

Sandro Martini commented on PIVOT-892:
--------------------------------------

ok, just found the problem ... all our troubles now are due to float math and 
related approximation of values.
I tried in some ways to rewrite the inner implementation of some of our 
Validators, but now I think that a better way could be to leave them as is 
(only small fixes, maybe something to commit today) deprecate them and add new 
ones (as the new, preferred way) backed by BigInteger and BigDecimal classes, 
with exact math. Of course the TextInputValidatorTest.java will be updated too, 
to give a sample usage (and best practices) for all them.

Otherwise I could rewrite only the final part of validation methods (like the 
isValid() in FloatRangeValidator.java), but transforming all values there (even 
min and max values) to BigDecimal and check range on them seems a not-so-good 
approach to me ...

So after this we could safely mark this as resolved, and add a new issue as 
Improvement, even for 2.0.3.
Roger, what do you think ?


As a side note, I'll add even an autoTrim boolean flag in an additional 
constructor for Validators that could be useful in some cases.

                
> DoubleValidator and FloatValidator do not allow exponents to be entered
> -----------------------------------------------------------------------
>
>                 Key: PIVOT-892
>                 URL: https://issues.apache.org/jira/browse/PIVOT-892
>             Project: Pivot
>          Issue Type: Bug
>          Components: wtk
>    Affects Versions: 2.0.2
>         Environment: All
>            Reporter: Roger Whitcomb
>            Assignee: Roger Whitcomb
>            Priority: Minor
>              Labels: validation
>             Fix For: 2.0.3
>
>         Attachments: 892.patch, num.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The DoubleValidator and FloatValidator classes rely on a default NumberFormat 
> instance to do parsing, however, a DecimalFormat is necessary in order to 
> recognize floating values entered with exponents.
> As a result, using one of these validators currently will fail to validate a 
> valid floating-point number such as "3.0e20".

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to