Wiki
Clone wikiXLIFF Toolkit / Validation
Validation
The library implements the Validation module. From a file, a group or a unit, you can call hasValidation()
to see if the object holds one or more validation rule (set directly on the object or inherited). A call to getValidation()
will return a Validation
object (even if there are currently no entries). That object holds a list of Rule
objects which contains all the information about the corresponding <rule>
element in the parent object.
For example the following code adds a new rule on a unit's validation object. The rule tests if the target text ends with a character ':':
#!java // Create a validation rule and add it Validation validation = unit.getValidation(); validation.add(new Rule("endsWith", ":")); validation.prepare(); // Verify if the rules are respected List<Issue> issues = validation.processRules(unit, "f1"); if ( issues == null ) { System.out.println("No rule found."); } else if ( issues.isEmpty() ) { System.out.println("No validation rule error found."); } else { System.out.println("One or more validation errors found:"); for ( Issue issue : issues ) { System.out.println("-- "+issue.getText()); } }
Updated