| Package | org.granite.validation |
| Class | public class DefaultMessageInterpolator |
| Implements | IMessageInterpolator |
IMessageInterpolator
interface, that transform a constraint message key into a human
readable error message. This implementation follows the JSR-303
specification recommendations (section 4.3.1) for message parameters
substitutions.
See also
| Method | Defined by | ||
|---|---|---|---|
|
Constructs a new
DefaultMessageInterpolator instance. | DefaultMessageInterpolator | ||
|
[static]
Returns the unique instance of the
ValidationMessages
class (shortcut for ValidationMessages.getInstance()). | DefaultMessageInterpolator | ||
|
interpolate(messageTemplate:String, constraint:IConstraint, value:String, locale:* = null):String
Interpolate the message template based on the contraint validation context
and substitute message parameters according to the JSR-303 specification
(section 4.3.1).
| DefaultMessageInterpolator | ||
|
split(messageTemplate:String):Array
[static]
Splits a message template into an array of string literals and
parameters.
| DefaultMessageInterpolator | ||
|
unescape(message:String):String
[static]
Unescape the given string parameter, removing extraneous backslashs.
| DefaultMessageInterpolator | ||
| DefaultMessageInterpolator | () | constructor |
public function DefaultMessageInterpolator()
Constructs a new DefaultMessageInterpolator instance.
| getBundle | () | method |
public static function getBundle():ValidationMessages
Returns the unique instance of the ValidationMessages
class (shortcut for ValidationMessages.getInstance()).
ValidationMessages —
the unique instance of the ValidationMessages
class.
|
| interpolate | () | method |
public function interpolate(messageTemplate:String, constraint:IConstraint, value:String, locale:* = null):StringInterpolate the message template based on the contraint validation context and substitute message parameters according to the JSR-303 specification (section 4.3.1). Standard or user specific validation bundles are used for parameters resolution.
ParametersmessageTemplate:String — the message to interpolate.
|
|
constraint:IConstraint — the constraint related to the interpolation.
|
|
value:String — the invalid value (according to the current constraint).
|
|
locale:* (default = null) — an optional locale used for message localization.
|
String — the interpolated error message.
|
See also
| split | () | method |
public static function split(messageTemplate:String):Array
Splits a message template into an array of string literals and
parameters. For example, split('Must be in [{min}, {max}]')
will return ['Must be in [', '{min}', ', ', '{max}', ']']).
See JSR-303 specification section 4.3.1.
messageTemplate:String — message template to be split into tokens.
|
Array — an array of string literals and parameters.
|
| unescape | () | method |
public static function unescape(message:String):StringUnescape the given string parameter, removing extraneous backslashs. See JSR-303 specification section 4.3.1.
Parametersmessage:String — the message to be unescaped.
|
String — the unescaped message.
|