Re: Silng Models Validation Framework
Hi Justin, yes you are probably right. However there are few downsides of this approach I can think of: - i'm not sure if it is worth to add such a big library to a project if you want to use just a small part - there is no fun :) But I will verify that. Maybe this solution will work for me. And then I will think of something else I can write myself. Kind Regards, Kasia On Thu, May 22, 2014 at 8:48 PM, Justin Edelson jus...@justinedelson.comwrote: Hi Kasia, Is it not possible to just use a JSR 303 implementation against your model objects? Since they are essentially just POJOs, I would expect this to be the case. Regards, Justin On Thu, May 22, 2014 at 2:40 AM, Katarzyna Kozlowska katarzyna.kozlow...@cognifide.com wrote: 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
Re: Silng Models Validation Framework
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
Re: Silng Models Validation Framework
Hi Kasia, Is it not possible to just use a JSR 303 implementation against your model objects? Since they are essentially just POJOs, I would expect this to be the case. Regards, Justin On Thu, May 22, 2014 at 2:40 AM, Katarzyna Kozlowska katarzyna.kozlow...@cognifide.com wrote: 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
Re: Silng Models Validation Framework
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
Re: Silng Models Validation Framework
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
Silng Models Validation Framework
Hello list, I was thinking about contributing to Sling and creating Sling Models Validation Framework. I was inspired by JSR 303 and I want to base my solution on annotations. I would really appreciate your feedback on my idea. Best Regards, Kasia