On 10/9/07, OlivierD <
[hidden email]> wrote:
>
> Hello,
>
> 1. We would like to validate an Integer field, alerting the user if he tries
> to add a non numeric char,
> but the field is automatically set to null if it is not numeric. We would
> like to show an error message
> and redisplay what the user has entered.
> It has already been discussed, but we can not find a workaround. What can we
> do, other than
> using a String and validate with a custom validator ?
In the next version of Grails (1.0-RC1) we store the original values
and type conversion errors during binding so if you do
def b = new Book(params)
you can check for errors:
if(b.hasErrors()) {}
And obtain the original input value:
b.errors.getFieldError("price")
>
> 2. We would like to validate the date, like the java Calendar class with
> setLenient(false). If the user
> tries to set the date to for eg. 30 february, we would like to show an error
> message and not set
> automatically the date to 1st or 2 march. When the validator is runned, the
> date fields (day,month,year)
> are already interpreted and tranformed to a Date Object so we can not check
> the original fields.
> What can we do ?
--
Graeme Rocher
Grails Project Lead
http://grails.org---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email