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

    }
}

Author: Angsuman Chakraborty

Software architect and entrepreneur with substantial experience in designing and developing enterprise software and services for Fortune 500 companies as well as startups. Enjoys solving complex software and bioinformatics problems. Currently heading a product development & outsourcing company specializing in Web 2.0 technologies. Specialties: Software Architecture, Software Design, Software Consultant, Java Developer, Web 2.0, Custom product development, Bioinformatics, Software Outsourcing, Management Consultant

Leave a Reply

Your email address will not be published. Required fields are marked *