[grails-dev] Grails Validation in CVS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[grails-dev] Grails Validation in CVS

graemer
Validation is now working in CVS, see the Blog sample app for example:

class Owner {
        @Property Long id;
        @Property Long version;
       
        @Property String firstName
        @Property String lastName
        @Property String email
        @Property String login
        @Property String password
        @Property Blog blog
       
        @Property constraints = {
                firstName(blank:false)
                lastName(blank:false)
                email(email:true, blank:false)
                login(length:5..15, blank:false)
                password(length:5..15, blank:false)
        }
}

And in the controller:

println "Checking errors"
if(firstOwner.validate()) {
        println "Errors"
        println firstOwner.errors
}

Now just have to add configuration of Spring MessageSources for
displaying the message in the view.

Cheers,
Graeme
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [grails-dev] Grails Validation in CVS

Dierk König
Cool. I especially like the Ranges. very groovy.
Mittie

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Montag, 14. November 2005 13:08
> To: [hidden email]
> Subject: [grails-dev] Grails Validation in CVS
>
>
> Validation is now working in CVS, see the Blog sample app for example:
>
> class Owner {
> @Property Long id;
> @Property Long version;
>
> @Property String firstName
> @Property String lastName
> @Property String email
> @Property String login
> @Property String password
> @Property Blog blog
>
> @Property constraints = {
> firstName(blank:false)
> lastName(blank:false)
> email(email:true, blank:false)
> login(length:5..15, blank:false)
> password(length:5..15, blank:false)
> }
> }
>
> And in the controller:
>
> println "Checking errors"
> if(firstOwner.validate()) {
> println "Errors"
> println firstOwner.errors
> }
>
> Now just have to add configuration of Spring MessageSources for
> displaying the message in the view.
>
> Cheers,
> Graeme
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Grails Validation in CVS

Guillaume Laforge-2
In reply to this post by graemer
On 14/11/05, Graeme Rocher <[hidden email]> wrote:
> Validation is now working in CVS, see the Blog sample app for example:

Well done, Mr Rocher!

> [...]
>
> println "Checking errors"
> if(firstOwner.validate()) {
>         println "Errors"
>         println firstOwner.errors
> }

By looking at this little sample I was wondering... shouldn't
validate() return true if everything was okay and false if there are
errors?

> Now just have to add configuration of Spring MessageSources for
> displaying the message in the view.

Okey dokey.

I'm pretty excited and enthousiasted about your work so far!

--
Guillaume Laforge
http://glaforge.free.fr/blog/groovy
Loading...