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 :
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 Is it possible or should I have to iterate over the collection in my controller and 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 ()
additional receipts
?
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
Post a Comment