{"id":618,"date":"2010-04-29T12:54:57","date_gmt":"2010-04-29T07:24:57","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=618"},"modified":"2010-06-14T21:19:49","modified_gmt":"2010-06-14T15:49:49","slug":"list-of-fields-in-error-of-a-domain-instance","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/list-of-fields-in-error-of-a-domain-instance\/","title":{"rendered":"List of fields in error of a domain instance"},"content":{"rendered":"<p>I have been working with domain and command object validation. I needed to get all the fields in error as a list so that I can display a single line error message  like : please enter valid values in the following fields- filed1, field2. Another use case was to check the list of fields for error. Here is the code to get list of errorneous fields:<\/p>\n<blockquote>\n<div class=\"code\">\n<pre lang=\"groovy\">\r\nList fieldsInError = domainInstance.errors.allErrors.collect {it.properties['field']}\r\n\r\n\/\/ Generate error message\r\n\r\nString errorMessage= \"Enter valid values in fields - ${fieldsInError.join(', ')}\"\r\n\r\n\/\/ check if both field1 and field2 are in error\r\n\r\nif(fieldsInError.containsAll(['field1', 'field2']){\r\n\t\/\/ Both the fields are in error irrespective of other fields\r\n}\r\n<\/pre>\n<\/div>\n<\/blockquote>\n<p>Hope it helps you guys too.<\/p>\n<p> ~~~~Bhagwat Kumar~~~~<br \/>\nbhagwat@intelligrape.com<br \/>\nIntelliGrape Software<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been working with domain and command object validation. I needed to get all the fields in error as a list so that I can display a single line error message like : please enter valid values in the following fields- filed1, field2. Another use case was to check the list of fields for [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/618"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}