gorm - Grails validation of a list objects -


I'm trying to get grails to validate the contents of a list of items, if I show the first code :

class item {contact recipient = new contact () list additional receipts = [] stable hamani = [additional receipts: contact] fixed constraints = {} static embedded = ['recipient']} Class contact {string name string email static barriers = {name (empty: incorrect) Mail (email: true, empty: incorrect)}}

Actually I have only one necessary contact ('recipient'), it works just fine:

  def i = new item () // will be wrong! I.validate () // will have an error for 'recipient.name' and 'recipient.email' i.errors  

Do I also add any of the attached I want to validate the 'additional' receipts in the Contacts:

  def i = new item () i.recipient = new contact (name: 'one name', email: 'Em Ail@example.com') // should be correct because all contacts are valid i.validate () i.extraRecipients & lt; & Lt; New contact () // Invalid invalid object // must be valid now should be valid! I.validate ()  

Is it possible or should I have to iterate over the collection in my controller and additional receipts ?

call valid () on each object

if I correctly question I understand that the error appears on the item domain object (error as an error for recipients, instead of cascading, throw the verification error on individual contact items in additional receipments, right?

If this is the case, then in the shortage of your item Something like this (this has not been tested but should be closed):

  Fixed constraints = (additional recipients (validators: {recipients -> recipients.all {it .validate ()}}}}  

You can get fantasy compared to that error message, resulting in the error string which the H recipient failed, but doing this The basic way is.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -