This issue can't be edited

Because it belongs to an archived project. Jira admins can restore projects from the archive.

Support interpolation of dynamically set message parameters

Description

Based on a question on stackoverflow, there seem to be use cases for setting message parameters dynamically, e.g. to put a dynamically determined valid value into the message:

If we don't find enough time for this, we should at least add an unwrap() method on ConstraintValidatorContext to allow for provider specific implementations.

Environment

None

Activity

Show:

Gunnar Morling December 17, 2012 at 8:27 PM

See http://lists.jboss.org/pipermail/beanvalidation-dev/2012-December/000684.html:

I think this would be helpful where validation is based on some sort of context which is not expressed in the constraint annotation attributes:

  • "Password must be at least {min} characters long for users in role {role}" (role is retrieved from the current user)

  • "Order number invalid. Reason: {reason}" (reason is one of several possible ones checked by the validator)

One could work around this by creating the message completely by yourself, but I think it would be nice to leave retrieval of the template etc. to BV and just put custom variables in. In combination with the EL feature, you could also put in variables evaluated in the EL expression.

Emmanuel Bernard December 17, 2012 at 8:04 PM

I guess a key referencing now for i18n is such a use case. But one need String formatting as well to properly format objects like dates.

Emmanuel Bernard December 17, 2012 at 8:03 PM

Any use case besides now? This problem could be fixed with concatenating the date to the template directly instead of asking the message interpolation engine to do the job.

Details

Assignee

Reporter

Participants

Emmanuel Bernard
Gunnar Morling

Components

Affects versions

Priority

Created November 30, 2012 at 10:49 AM
Updated February 7, 2013 at 7:55 PM