You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Bertrand Delacretaz (JIRA)" <ji...@apache.org> on 2014/10/08 11:14:34 UTC

[jira] [Resolved] (SLING-4010) Allow validator to set a custom failure message

     [ https://issues.apache.org/jira/browse/SLING-4010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz resolved SLING-4010.
----------------------------------------
    Resolution: Fixed
      Assignee: Bertrand Delacretaz

That was quick! Committed in revision 1630039, thanks for your contribution.

> Allow validator to set a custom failure message
> -----------------------------------------------
>
>                 Key: SLING-4010
>                 URL: https://issues.apache.org/jira/browse/SLING-4010
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Konrad Windszus
>            Assignee: Bertrand Delacretaz
>              Labels: validation, validator
>
> Currently the Validator may only return a boolean value or an exception in case the validator was called with invalid parametrization (https://github.com/apache/sling/blob/trunk/contrib/validation/api/src/main/java/org/apache/sling/validation/api/Validator.java).
> In some cases the validator could give some important information about why the validation failed. This is e.g. the cause for a reference validator where the cause for a failed validation could be:
> # referenced resource is not existent
> # referenced resource is not having the right resource type
> # referenced resource is not activated
> So instead of only returning a boolean value, it should also be possible to return a failure message.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Re: [jira] [Resolved] (SLING-4010) Allow validator to set a custom failure message

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Oct 8, 2014 at 1:20 PM, Konrad Windszus <ko...@gmx.de> wrote:
> ...I am fine with changing the return value to something more sophisticated, although currently
> I don’t see a reason for a validator to return multiple failure messages....

While I haven't used this module so far, this looks similar to health
checks, where the result [1] uses a log-like stream of messages. Being
able to include DEBUG and INFO messages helps understand the
validation, and with a log you can easily aggregate the results of
multiple validators, while keeping the details about each of them.

It might make sense to use the same or a similar mechanism for validation.

-Bertrand

[1] https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/Result.java

Re: [jira] [Resolved] (SLING-4010) Allow validator to set a custom failure message

Posted by Konrad Windszus <ko...@gmx.de>.
I am fine with changing the return value to something more sophisticated, although currently I don’t see a reason for a validator to return multiple failure messages.
Functionality-wise the possible String return values 1) null, 2) empty string and 3 ) non-empty string cover the three main use cases for me:
1) validation successful
2) validation not successful with standard error message
3) validation not successful with custom error message
Konrad



On 08 Oct 2014, at 11:21, Radu Cotescu <ra...@apache.org> wrote:

> Hi,
> 
> While I do understand the need for clearer messages about why a validator
> returns false for a simple validation operation I would not rely on Strings
> for getting the result.
> 
> Instead I would return something similar to the ValidationResult - an
> object encapsulating a boolean value for the result, together with a
> List<String> for retrieving more detailed messages about the Validator's
> reasons for returning false.
> 
> WDYT?
> 
> On Wed, Oct 8, 2014 at 12:14 PM, Bertrand Delacretaz (JIRA) <jira@apache.org
>> wrote:
> 
>> 
>>     [
>> https://issues.apache.org/jira/browse/SLING-4010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>> ]
>> 
>> Bertrand Delacretaz resolved SLING-4010.
>> ----------------------------------------
>>    Resolution: Fixed
>>      Assignee: Bertrand Delacretaz
>> 
>> That was quick! Committed in revision 1630039, thanks for your
>> contribution.
>> 
>>> Allow validator to set a custom failure message
>>> -----------------------------------------------
>>> 
>>>                Key: SLING-4010
>>>                URL: https://issues.apache.org/jira/browse/SLING-4010
>>>            Project: Sling
>>>         Issue Type: Improvement
>>>         Components: Extensions
>>>           Reporter: Konrad Windszus
>>>           Assignee: Bertrand Delacretaz
>>>             Labels: validation, validator
>>> 
>>> Currently the Validator may only return a boolean value or an exception
>> in case the validator was called with invalid parametrization (
>> https://github.com/apache/sling/blob/trunk/contrib/validation/api/src/main/java/org/apache/sling/validation/api/Validator.java
>> ).
>>> In some cases the validator could give some important information about
>> why the validation failed. This is e.g. the cause for a reference validator
>> where the cause for a failed validation could be:
>>> # referenced resource is not existent
>>> # referenced resource is not having the right resource type
>>> # referenced resource is not activated
>>> So instead of only returning a boolean value, it should also be possible
>> to return a failure message.
>> 
>> 
>> 
>> --
>> This message was sent by Atlassian JIRA
>> (v6.3.4#6332)
>> 


Re: [jira] [Resolved] (SLING-4010) Allow validator to set a custom failure message

Posted by Radu Cotescu <ra...@apache.org>.
Hi,

While I do understand the need for clearer messages about why a validator
returns false for a simple validation operation I would not rely on Strings
for getting the result.

Instead I would return something similar to the ValidationResult - an
object encapsulating a boolean value for the result, together with a
List<String> for retrieving more detailed messages about the Validator's
reasons for returning false.

WDYT?

On Wed, Oct 8, 2014 at 12:14 PM, Bertrand Delacretaz (JIRA) <jira@apache.org
> wrote:

>
>      [
> https://issues.apache.org/jira/browse/SLING-4010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
> ]
>
> Bertrand Delacretaz resolved SLING-4010.
> ----------------------------------------
>     Resolution: Fixed
>       Assignee: Bertrand Delacretaz
>
> That was quick! Committed in revision 1630039, thanks for your
> contribution.
>
> > Allow validator to set a custom failure message
> > -----------------------------------------------
> >
> >                 Key: SLING-4010
> >                 URL: https://issues.apache.org/jira/browse/SLING-4010
> >             Project: Sling
> >          Issue Type: Improvement
> >          Components: Extensions
> >            Reporter: Konrad Windszus
> >            Assignee: Bertrand Delacretaz
> >              Labels: validation, validator
> >
> > Currently the Validator may only return a boolean value or an exception
> in case the validator was called with invalid parametrization (
> https://github.com/apache/sling/blob/trunk/contrib/validation/api/src/main/java/org/apache/sling/validation/api/Validator.java
> ).
> > In some cases the validator could give some important information about
> why the validation failed. This is e.g. the cause for a reference validator
> where the cause for a failed validation could be:
> > # referenced resource is not existent
> > # referenced resource is not having the right resource type
> > # referenced resource is not activated
> > So instead of only returning a boolean value, it should also be possible
> to return a failure message.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
>