public interface OnFailResult
OnFail
result.
Contains details of a validation rule failure.
ResourceBundles
).
The base bundle name is derived from the rules src. The Validation message base bundle name for
a rules source "/a/b/c/rulesX.xml" would be "a/b/c/i18n/rulesX", which means that localized
ResourceBundle
files would need to be supplied on the classpath/filesystem as "/a/b/c/i18n/rulesX.properties",
"/a/b/c/i18n/rulesX_en.properties", "/a/b/c/i18n/rulesX_de.properties" etc. The message property
names are based on the rule property names e.g. the message bundle property name for rule "orderId"
would also need to be "orderId".
The validation cartridge supports application of FreeMarker templates on the localized messages,
allowing the messages to contain contextual data from the bean context, as well as data about the actual
rule failure. FreeMarker based messages must be prefixed with "ftl:" and the contextual data is references
using the normal FreeMarker notation. The beans from the bean context can be referenced directly, while the
RuleEvalResult
and rule failure path can be referenced through the "ruleResult" and "path"
beans.
Example message using RegexProvider
rules:customerId=ftl:Invalid customer number '${ruleResult.text
}' at '${path}'. Customer number must match pattern '${ruleResult.pattern
}'.
Modifier and Type | Field and Description |
---|---|
static String |
MAX_FAILS
Maximum failures global param key.
|
Modifier and Type | Method and Description |
---|---|
String |
getFailFragmentPath()
Get the path to the fragment on which the validation rule failure
occured.
|
RuleEvalResult |
getFailRuleResult()
Get the validation failure
RuleEvalResult . |
String |
getMessage()
Get a localized message for the validation failure.
|
String |
getMessage(Locale locale)
Get a localized message for the validation failure.
|
static final String MAX_FAILS
String getFailFragmentPath()
RuleEvalResult getFailRuleResult()
RuleEvalResult
.RuleEvalResult
.String getMessage()
Locale
.
See Localized Messages.String getMessage(Locale locale)
Copyright © 2020. All rights reserved.