Create a Custom Validator for control validation
This sample plugin demonstrates custom validation for an individual control. For an example of how to validate an entire screen, refer to the Create a Custom Validator for screen validation example.
About the sample
In this example, we validate the age details entered by the user to ensure it is a number greater than 0 and less than 130.
The sample code demonstrates:
- Handling the OnValidateControlEvent event
- Extracting the current value of a control and validating it using custom logic
- Adding an error to the TransactionResult object in the OnValidateControlEvent event
The sample code needs the following to run:
- CustomControlValidator plugin (examples\interview-engine\custom-control-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 CustomControlValidator.jar file (located in examples\interview-engine\custom-control-validator) into Web Determinations; for more information, refer to Create a Plugin. If you wish to modify the CustomControlValidator code, do the following:
- Copy the code for the CustomControlValidator plugin
- Modify the validation code in the handleEvent method
- Compile and JAR or DLL the CustomControlValidator
- Run a Web Determinations Interview
Source
To view the source code for the CustomScreenValidator sample, refer to examples\interview-engine\custom-control-validator in the Java or .NET runtime zip file.