You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ndario <da...@yahoo.com> on 2008/08/25 13:34:38 UTC
regex validator and BigDecimal
Hello,
I am trying to enforce BigDecimal number format with regex validator but
validation simply does nothing. If I apply the same validator to the String
property, validator works but for some reason does not work with BigDecimal.
I guess the reason is that validation is applied to converted BigDecimal
object but not on the string which user entered.
Is there any way to validate the string before conversion to BigDecimal?
thanks!
Dario
--
View this message in context: http://www.nabble.com/regex-validator-and-BigDecimal-tp19142200p19142200.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: regex validator and BigDecimal
Posted by ndario <da...@yahoo.com>.
I should have said that I do have custom BigDecimal converter which throws
TypeConversionException if conversion fails.
But users are still allowed to enter something like "344,5,6" which converts
successfuly but converted value may not be the one user wanted to enter.
That is why i want to give a warning that format is incorrect.
I guess that cannot be done with regex validator and BigDecimal?
--
View this message in context: http://www.nabble.com/regex-validator-and-BigDecimal-tp19142200p19145282.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: regex validator and BigDecimal
Posted by Oleg Mikheev <mi...@bigfoot.com>.
ndario wrote:
> Is there any way to validate the string before conversion to BigDecimal?
The right (and default) way of handling conversion errors is to
use the Conversion Error Interceptor:
http://struts.apache.org/2.x/docs/conversion-error-interceptor.html
There is no converter for BigDecimal, but it takes almost no
effort to create one:
http://struts.apache.org/2.0.11.2/docs/type-conversion.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: regex validator and BigDecimal
Posted by ea...@gmail.com.
If the conversion to BigDecimal fails that either means that the input
is blank of invalid. Would you get the same effect as a regex
validatir if you made the BigDecimal property a required field?
On 8/25/08, ndario <da...@yahoo.com> wrote:
>
> Hello,
>
> I am trying to enforce BigDecimal number format with regex validator but
> validation simply does nothing. If I apply the same validator to the String
> property, validator works but for some reason does not work with BigDecimal.
> I guess the reason is that validation is applied to converted BigDecimal
> object but not on the string which user entered.
>
> Is there any way to validate the string before conversion to BigDecimal?
>
> thanks!
>
> Dario
> --
> View this message in context:
> http://www.nabble.com/regex-validator-and-BigDecimal-tp19142200p19142200.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Ealden Esto E. EscaƱan
http://blog.ealden.net
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org