Create a Custom Validator for screen validation
This sample plugin demonstrates screen-wide custom validation. Custom validation of screens is useful when data validity depends on a combination of values from different controls. For an example of how to validate an individual control, refer to the Create a Custom Validator for control validation example.
About the sample
In this example, we validate the country and postcode details entered by the user using the following rules:
- Australian postcodes must consist of exactly 4 digits
- Postcodes in other countries are not validated
The sample code demonstrates:
- Handling the OnValidateScreenEvent event
- Extracting the current value of a control and validating it using a Regular Expression
- Adding an error to the TransactionResult object in the OnValidateScreenEvent event
The sample code needs the following to run:
- CustomScreenValidator plugin (examples\interview-engine\custom-screen-validator)
- CustomValidatorExample rulebase (examples\rulebases\compiled\CustomValidatorExample.zip)
To setup this scenario
- Copy the rulebase .zip file (CustomValidatorExample.zip) from examples\rulebases\compiled to the rulebase folder in Web Determinations (for example, <webroot>\WEB-INF\classes\rulebases)
- Copy and install the CustomScreenValidator.jar file (located in examples\interview-engine\custom-screen-validator) into Web Determinations; for more information, refer to Create a Plugin. If you wish to modify the CustomScreenValidator code, do the following:
- Copy the code for the CustomScreenValidator plugin.
- Modify the validation code in the handleEvent method.
- Compile and JAR or DLL the CustomScreenValidator.
- Run a Web Determinations Interview
Source
To view the source code for the CustomScreenValidator sample, refer to examples\interview-engine\custom-screen-validator in the Java or .NET runtime zip file.