Hi again, generally I like the resource base validation very much. However after going through jira Radu provided I am not sure if it is proper solution for my problem. First of all I don't want to filter improper data or stop them from being saved to the repository. I just want to get validation errors, if any, and display them in the ui. The second part is that when I am using Sing Models my abstraction layer is not aware of the resource anymore and I would like to keep it that way. For me the perfect solution for Sling Models would be designed in the way where user must only use simple annotations like:
@NotBlank @Length(max=25, message="Title field must not be longer then 25 characters") private String title and there would be a validate() method returning some kind of validation results map/list based on annotations Important part is that there should be a predefined set of annotations with default messages, but the possibility to add some custom ones is a must. Therefore right now I can see one point we could merge this to different approaches and it is this common set of simple code validating separate values. I would love to discuss this solution further. Kind regards, Kasia On Tue, May 20, 2014 at 12:13 PM, Konrad Windszus <konra...@gmx.de> wrote: > The problem with connecting something like that with Sling Models is the > way the adaptTo method was specified. > It is supposed to return null and never throw an exception. So all > exceptions being caused by e.g. validation errors must be caught within > Sling Models. Currently I don’t see any way to propagate those exceptions > across the adaptTo boundary. That might already be a problem when for > example some required properties are missing. It is much harder to debug > because the exception is caught within the Sling Models framework. > I would like to have the possibility to instantiate a model class and to > be able to catch all potential exceptions within my own code. > Konrad > > On 19 May 2014, at 14:53, Bertrand Delacretaz <bdelacre...@apache.org> > wrote: > > > On Mon, May 19, 2014 at 1:43 PM, Radu Cotescu <r...@cotescu.com> wrote: > >> ...Maybe we can revive that topic and merge the two ideas.... > > > > That would be great, IIRC Radu's SLING-2803 validator is meant to be > > generic, using it within Sling models should then just be another use > > case. > > > > -Bertrand > >