|
ValidWhenParser.java is a generated by antlr.
Any changes need to be made to the ValidWhenParser.g file and the ValidWhenParser.java re-generated. Patches are preferred in "diff" format. Niall Changing this to an enhancement request.
Changing the product to Struts - validwhen is not part of Commons Validator
Don Brown made changes - 23/Apr/06 04:49 AM
Niall Pemberton made changes - 09/Nov/06 02:29 AM
Makes sense. The ValidWhenParser defines a DECIMAL_LITERAL to be:
DECIMAL_LITERAL : ('-')? ('1'..'9') ('0'..'9')*; Which doesn't support decimals (despite the name). Making it support decimals appears to be trickier than just adding the pattern for a decimal format - you have to split DECIMAL_LITERAL and INTEGER_LITERAL so the right types of objects are made, and then you need to find a way to stop the DECIMAL, INTEGER clashing with the INTEGER_LITERAL, OCTAL_LITERAL and IDENTIFIER. Way beyond my Antlr knowledge at the moment, but it does explain why the examples I looked at get complex in this area.
Paul Benedict made changes - 25/Aug/07 04:52 PM
I propose a fix by instantiating BigDecimal instead of Integer. Therefore, the developer would first run the integer or double validator (ensuring correct type) and then validwhen.
Paul Benedict made changes - 26/Aug/07 11:43 PM
Paul Benedict made changes - 26/Aug/07 11:43 PM
Paul Benedict made changes - 26/Aug/07 11:44 PM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Corrects issue when trying to compare doubles.
I have added support for comparing doubles when using validwhen. I have tested
it and it works correctly now in my application. I noticed that before it did
a check to see if the values from the form are of type Integer.class, but after
reviewing the code it seems that this case can never occur. Everywhere where
the value of the property from the form is retrieved
ValidatorUtils.getValueAsString(bean, property) is used, thus the value should
always be a string. I went ahead and left the code to check for objects of
type Integer.class and now Double.class, but if they are unneeded they could be
removed.
thanks.