Menu
  • HOME
  • TAGS

Why can't I return global message keys within custom field validators?

grails,gorm,grails-2.3,grails-validation

When using the three parameter (value, object, errors) version of the validate closure, the underlying code assumes that all errors will be added to the errors object. In order to returning a string or list of strings representing a message key. The behavior is the same if using Command Objects...

Grails validation over own domain

hibernate,grails,grails-domain-class,grails-controller,grails-validation

I'd probably use something like this: validator: { val, obj -> if (obj.recipients.findAll{invoiceType == 'O'}.size() > 1) return "invoiceRecipient.original.max.exceed" This way you should be able to prevent Hibernate from trying to flush dirty objects and in the process revalidate this object....

Grails Error Code

grails,gorm,unique-constraint,grails-domain-class,grails-validation

The Error Code is burried deep within the object. It will be one of the items in the list that is returned by calling the following code, where 'e' is the exception object. e.getErrors().getFieldError() You can also get just the code ("unique" in this case) from the exception by calling...

Require current password to set a new password

ruby-on-rails,ruby,validation,ruby-on-rails-4,grails-validation

This method def current_password errors[:current_password] << 'Incorrect password' unless self.current_password == self.password end calls itself: that's why you're getting the stack too deep error - it's stuck in a loop calling itself endlessly. What you're attempting to do is confusing because the current_password method is overwriting the one created by...