Validation of Fields and Records
You can create validation rules at two levels: that of the individual field, as well as that of the entire record. The Validation Rule form shown in the screenshot below is displayed when you click New Rule; the same form is shown for both field validation and record validation.
In the form, enter an XPath expression that returns Boolean true() or false(). If the expression is invalid XPath, then the invalidity is flagged with an error message in red. If the expression is valid XPath but returns some other value than Boolean true() or false(), then the rule is considered to be an error but no XPath error is flagged. It is up to you to ensure that the expression returns a Boolean result. See (i) the screenshot below for an example of such an expression, and (ii) the note below about editing XPath expressions.
The validation rule shown in the screenshot above could be used to validate a record to ensure that at least an email address or a telephone number has been entered for the record. You could add further validation rules at the level of the telephone number field and/or email address fields: for example, to ensure the correct telephone number format and/or email address pattern. Note that a predefined rule to validate email addresses for correct pattern is built-in for field validation.
For each rule, you can specify whether a failed validation is to be considered an error or a warning. In the case of an error, the record will not be saved. You can also enter the text of a suitable error/warning message; this will be displayed if validation fails.
Note about editing XPath expressions: The form for editing XPath expressions has three tabs: (i) Samples provides a random example of an XPath expression, such as: (a) the concatenation of three values (two values from other fields and a comma separator); or (b) an exists function to test whether a field contains some content; (ii) Fields lists the names of all the record's fields in alphabetical order so that they can be correctly entered in the XPath expression; (iii) Copy lists a selection of XPath expressions that contain various useful functions, which you can copy into your expression and modify.
See Altova's XPath 3.0 and 3.1 Training for information and examples of how to use XPath expressions and functions.