Grails: Validating User Domain class

Grails provides support for validating fields. Here is a typical User class with field validation. It ensure that email address & url is of proper format, login is unique and password is not openly displayed.

package com.taragana
class User {
    String login
    String password
    String email
    String url
    static constraints = {
        login unique: true
        password password: true
        email email: true
        url url: true
    }
}

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.