[ 
https://issues.apache.org/jira/browse/WICKET-5902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14534610#comment-14534610
 ] 

Sven Meier commented on WICKET-5902:
------------------------------------

If PatternValidator would get this 'improvement', you could equally well add 
this field to all other validators too. And I wouldn't like that.

I'd prefer a more generic solution - what about letting PatternValidtor use the 
pattern as key too?

        ValidationError error = new ValidationError();
        error.addKey("PatternValidator." + pattern.pattern());
        error.addKey(this);
        error.setVariable("pattern", pattern.pattern());
        validatable.error(decorate(error, validatable));

This way you can easily provide different messages for different patterns.

> Allow to easily override the error key of a PatternValidator
> ------------------------------------------------------------
>
>                 Key: WICKET-5902
>                 URL: https://issues.apache.org/jira/browse/WICKET-5902
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Guillaume Smet
>            Priority: Minor
>
> By default, PatternValidor builds its error message by including the pattern, 
> which might be a complicated regexp.
> In our applications, we often override the error message key to provide a 
> user-compliant error message.
> We currently do it by overriding decorate() but it would be simpler with a 
> setter on PatternValidator.
> PR to come.



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

Reply via email to