Validation of a rulebase is done in two ways: using error and warning events, and by specifying validations on user input. Validation will warn or prevent the user from entering values which do not meet certain criteria when running the rulebase.
Error and warning events are types of rules that specify an action to be taken in a process outside of the rulebase. They operate in a similar way to normal rules, except that instead of inferring an attribute, they execute a command (ie firing the command specified in the conclusion line of the event rule). Event rules participate in inferencing only – not in the question search.
Oracle Policy Modeling also allows you to specify validations on the user input at runtime. These validations are set using minimum and maximum values and regular expressions on variable attributes. These input validations are triggered at the point which the value is submitted to the Engine and not during inferencing.
Specify minimum and maximum values
An error event is used to pass a message to the user, and prevent them from continuing an investigation until the condition which triggered that error no longer applies.
To write an error event rule use the following syntax for the conclusion line of the rule:
For example,
Error("You can only be married to one person.") if
the applicant's number of spouses > 1
A warning event is used to pass a message to the user, but permits them to continue despite the condition which triggered that warning.
To write a warning event rule use the following syntax for the conclusion line of the rule:
For example,
warning("The date of birth you have entered is in the future.") if
the person's date of birth > the current date
Minimum and maximum values can be specified for number, currency, date, time of day, and date/time variables to ensure that data entered by the user falls within a certain range. Values must be specified in the correct format.
To specify minimum and maximum values for an attribute:
Regular expressions can be used in Oracle Policy Modeling to ensure that the data entered by the user matches an expected format. You can also specify a custom error message to display when the user enters data that does not conform to the format. An example of where you might use a regular expression would be to check that a driver's license number contains the correct number of digits and / or alphabetical characters in the correct relative positions.
Note: Regular expressions are only recommended for use with text variable attributes. They are not recommended for use with number, currency, time of day, or date and time variable attributes. It is currently possible to specify a regular expression for a non-text variable attribute in Oracle Policy Modeling, but this functionality will be removed in a future release. In any case, regular expressions that include spaces and brackets can only be used on text variables (spaces and brackets are not valid input characters for other variable types).
Common regular expressions are given below:
Use | Regular Expression |
---|---|
To check basic types of email addresses | ^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$ |
To check the data entered follows a certain format: 2 letters 6 numbers 1 letter (eg AB123456C) | ^[A-Za-z]{2}[0-9]{6}[A-Za-z]$ |
To check the data is a phone number in the format: (NN) NNNN NNNN where N = number. This example will match with or without the 2 spaces separating the sections. | ^(\(0[0-9])\) ?[1-9][0-9]{3} ?[0-9]{4}$ |
To validate that the number of words in a text input does not exceed a certain number. In this example, the value N is equal to the number of permitted words minus one, so if the permissible number of words is 8 then, N = 7. | ^\s*(\S+(\s+\S+){0,N}\s*)?$ |
To check a National Insurance Number (NINO) | ^[A-CEGHJ-PR-TWZ][A-CEGHJ-NPR-TWZ] ?\d{2} ?\d{2} ?\d{2} ?[ABCD] |
TIP: There are a number of internet resources available on crafting regular expressions(eg http://en.wikipedia.org/wiki/Regex).
To specify a regular expression for an attribute: