sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Lietz (JIRA)" <>
Subject [jira] [Commented] (SLING-6660) Validators should expose their id and severity
Date Mon, 20 Mar 2017 14:38:41 GMT


Oliver Lietz commented on SLING-6660:

bq. Because that way this information is duplicated. Even if we move the logic of exposing
ID and severity from the service property into an abstract class, a Validator could decide
to overwrite those methods or not derive from the abstract class at all. That is something
I want to prevent, because that would prevent overwriting those values and also does not allow
to easily debug those values (via the web console).

There is no need to duplicate, you can delegate easily:

    private void activate(final ValidatorConfiguration configuration) {
        this.configuration = configuration;
    public String getId() {
        return configuration.validator_id();

bq. I understand that, but IMHO the code in ValidationModelRetrieverImpl is easy to understand
and pretty straightforward. With OSGi R7 we might even fully rely on field injection. ValidatorAndSeverity
is only used within validation models, therefore all consumers of Sling Validation won't ever
get in contact with that class. Only if you want to implement your own ValidationModelProvider
you need that class.

Then move {{ValidatorAndSeverity}} out of API. But still {{ValidationModelRetrieverImpl}}
is agnostic to runtime modifications of service properties (SLING-6659) – in my opinion
broken and worth a refactoring.

> Validators should expose their id and severity
> ----------------------------------------------
>                 Key: SLING-6660
>                 URL:
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions, Validation
>            Reporter: Oliver Lietz
> {{Validator}}s should expose their {{id}} and {{severity}} (maybe from service properties,
but haven't to be service properties at all) by their own:
> {noformat}
> [...]
> public interface Validator <T> {
> [...]
>     String getId(); //
>     int getSeverity(); // validator.severity
> [...]
> }
> {noformat}
> This addition allows less code in {{ValidationModelRetrieverImpl}} and makes {{ValidatorAndSeverity}}

This message was sent by Atlassian JIRA

View raw message