An instance of the Spring Errors interface that contains data binding and/or validation errors.


def user =  new User(params)

if(user.validate()) { // do something with user } else { user.errors.allErrors.each { println it } }


The errors property is an instance of Spring's Errors interface which is used by Grails during Data Binding to store type conversion errors and during Validation when calling the validate or save methods.

You can create your own errors using the reject and rejectValue methods:

if (params.password != params.confirm_password) {

user.errors.reject('user.password.doesnotmatch', // Error code within the grails-app/i18n/ ['password', 'class User'] as Object[], // Groovy list cast to Object[] '[Property [{0}] of class [{1}] does not match confirmation]') // Default mapping string

// The following helps with field highlighting in your view user.errors.rejectValue('password', // Field in view to highlight using <g:hasErrors> tag 'user.password.doesnotmatch') // i18n error code

render(view:'signup', model:[user:user]) }