Show Table of Contents
3.13. Smooks.filterSource
The Smooks.filterSource captures the validation results. When the filterSource method returns, the ValidationResult instance will contain all validation data.
This code shows how to make Smooks perform message fragment validation:
ValidationResult validationResult = new ValidationResult(); smooks.filterSource(new StreamSource(messageInStream), new StreamResult(messageOutStream), validationResult); List<OnFailResult> errors = validationResult.getErrors(); List<OnFailResult> warnings = validationResult.getWarnings();
As you can see, individual warning and error validation results are made available from the
ValidationResult object in the form of OnFailResult instances, each of which provide details about an individual failure.
The Validation Cartridge also allows you to specify localized messages relating to validation failures. You can define these messages in standard Java ResourceBundle files (which use the
.properties format).
Note
The base name of the validation message bundle is derived from the rule source ("src") by dropping the rule source file extension and adding an extra folder named
i18n. For example, if you have an MVEL ruleBase source of /org/milyn/validation/order/rules/order-rules.csv, the corresponding validation message bundle base name will be /org/milyn/validation/order/rules/i18n/order-rules.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.