We usually have to Google to find the error code of the validation error message if you are new Grails developer. This blog gives the simplest way to get error code for validation error message.

Suppose we have a Domain class User

This is my simple controller code to save user.

Now you have to add a line to get the error code for validation error

So the update save action is look like

Now when you try to save the user with error, you found this output in console.

As figure shows, you have list of error code for each property and all are right. Use anyone.

If this blog is helpful for you please appreciate work by comment.