tag:blogger.com,1999:blog-3237724005744642470.post6190124995247980845..comments2020-05-08T12:31:27.297+01:00Comments on Captain Debug's Blog: The JSR 303 javax.validation.Payload Class - WTF???Roger Hugheshttp://www.blogger.com/profile/07042290171112551665[email protected]Blogger4125tag:blogger.com,1999:blog-3237724005744642470.post-9856181863642710562013-06-21T09:48:05.429+01:002013-06-21T09:48:05.429+01:00Regarding your comment that the example code does ...Regarding your comment that the example code does not compile. Note, in your case you are using severity classes whereas the example uses interfaces and an interface can very well extend another interface ;-)<br /><br />About the use of such a features, there are some as suggested by the other comments and some people might not only be interested in a simple fail or pass, but also in a severity. Either way, in most cases you can ignore the payload attribute. The only thing you have to do is to add it to your custom constraint.Hardy Ferentschikhttps://www.blogger.com/profile/09313517265555235117[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-31937818324962164302013-06-20T11:27:17.171+01:002013-06-20T11:27:17.171+01:00I may have another usecase. Check that: http://st...I may have another usecase.<br /><br />Check that:<br />http://stackoverflow.com/questions/17211209/pass-flexible-data-in-java-annotations-exemple-beanvalidation-payloadSébastien Lorberhttps://www.blogger.com/profile/16535575273136501866[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-88118757962141091712013-06-20T11:26:59.401+01:002013-06-20T11:26:59.401+01:00I may have another usecase too. Check that: http:...I may have another usecase too.<br /><br />Check that:<br />http://stackoverflow.com/questions/17211209/pass-flexible-data-in-java-annotations-exemple-beanvalidation-payloadSébastien Lorberhttps://www.blogger.com/profile/16535575273136501866[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-79628415786997821262012-05-24T12:01:09.180+01:002012-05-24T12:01:09.180+01:00I actually found a use for the payload attribute. ...I actually found a use for the payload attribute. Our application reads in properties from a tab-delimited file, marshals them into a bean, and then uses JSR303 to validate it. One of the requirements is that when validation fails, we tell the user the field number in the file that failed validation so they can fix it. Unfortunately, there is nothing in the ConstraintViolation interface that would give us such information directly. Previously, our plan was to make a map of property paths to field numbers, and then use the getPropertyPath() method to do a lookup on this map to find the field number. But after reading your blog post, I realize that we can just put a payload on each constraint which is equal to its field number and use this information when validation fails.Anonymous[email protected]