To validate related records of a record (cascade validation), do the following:
Book.author
.RecordValidity
.Author.books
.RecordCollectionValidity
. Important: Make sure the validation does not result in infinite recursive validation (the relationship record does not validate the parent record).
validate()
function on the main record.Example:
def Author author := new Author(books -> {new Book(title -> null)}, name -> null); validate (author, null, null, null);
Since the Author.books.RecordCollectionValidity constraint definesRecordCollectionValidity
, the validate() checks also the created book constraints and violations on the constraints Author.name.NotNull and Book.title.NotNull are returned.