|
|
|
|
|
|
While not explicitly stated, the [algorithm for message interpolation|http://beanvalidation.org/1.1/spec/#default-resolution-algorithm] also covers the case of nesting message parameters within EL expressions, which allows for use cases which refer to messages from the resource parameters or constraint attributes (which are resolved via parameter interpolation) which then are used within EL expressions. The following gives an example:
{code} @ThresholdMax( value=10, messageThreshold=50, message="${validatedValue > {messageThreshold} ? '{muchTooLarge.message}' : '{aBitTooLarge.message}'}") int myInt = ...; {code}
This case should be resolved by the algorithm as follows:
* After step 3 (resource bundle replacements): _$\{validatedValue > \{messageThreshold\} ? 'Viel zu groß' : 'Zu groß'\}_ * After step 4 (resolution of constraint attributes): _$\{validatedValue > 50 ? 'Viel zu groß' : 'Zu groß'\}_ * After step 5 (EL evaluation): _Viel zu groß_ or _Zu groß_, depending on the threshold value
To clarify that such nesting is considered legal, an example as this should be added to the spec and a test to the TCK.
References:
* [Mailing list discussion|http://lists.jboss.org/pipermail/beanvalidation-dev/2013-November/000942.html] * [Original forum post|https://forum.hibernate.org/viewtopic.php?f=9&t=1029782]
|
|
|
|
|
|