Validation of data
When developers design a View, all the Fields and controls that the task requires are added. As a Pega Business Architect (BA), you want to ensure that the data values that users enter are valid. Valid data is necessary for the system to process the information without error.
In this topic, you examine various ways to ensure that the system can validate the data that users enter for optimal processing of the workflow.
Data validation requirements
Confirming that data input by users is valid helps to ensure that the workflow can complete end-to-end without problems or errors.
The following table outlines examples of data validation requirements:
Data requirements | Examples |
---|---|
Use only the correct type of data. | For example, users must enter a number in a Total purchase units field. |
Restrict data to possible values. | For example, users can only select a valid loan type by selecting the type from a list of options. |
Ensure that data fits the business logic. | For example, a Date of birth field must be in the past. |
To prevent processing errors, Pega Platform™ provides Field Types and controls to support validation requirements. Selecting the right control might be sufficient to satisfy a validation requirement. In cases where a control or Field Type is insufficient to perform data validation, Pega Platform provides data validation by using business logic to test fields with conditions.
For example, you can use a Date only Field Type to ensure that the data entered by users is a date, regardless of whether the format is dd/mm/yyyy or mm/dd/yyyy. But the Date only Field Type does not ensure that a Start date field in an employment history form captures a date in the past. Instead, you can validate that the date is in the past by using business logic.
Data validation with controls
Controls provide the most common approach to validation. You can validate user input with controls by leveraging control types, required fields, and editable settings.
Control types
Using the correct control type for a specific purpose ensures users enter valid values. The following table shows example use cases for different control types:
Control type | How the control helps validation | Use case |
---|---|---|
Date Time | Selecting a date from a calendar icon ensures that users enter a date in a valid format. | Users must enter a date that includes day, month, and year. |
Radio buttons | Restricts choices to a set of valid values and allows users to select only one value. You can use radio buttons when only a small number of options (for example, fewer than five) is available. | Users must select one of three possible loan types. The user must see all types on the form. |
Dropdown | Restricts valid values to the ones that appear in the list. A drop-down list presents the options only when users click the control; this helps reduce the clutter on the form. | Users must select one of 10 types of office chairs from a list. The options do not need to be displayed on the form. |
Autocomplete | When users enter one or more values in the control, the control filters the available options. This helps users find an option in a list if there is a large number (for example, more than 20) of possible options. | Users must select the country in which they reside from a list. The user can enter text in the control to help find the right country. |
Checkbox | Users can select the check box or leave it blank. This option ensures that a true/false property is either true (selected) or false (unselected). | Users select an option to purchase extra travel insurance. |
Required fields
Configuring a control as a required field ensures that the user enters a value. If there is no value, users receive an error when they try to submit a form. In the rewards program profile example, you decide to configure the Date of birth as a required field. If users do not enter a date in the field, an error message appears when users attempt to submit the form. The error message does not appear if there is a date in the field.
Business logic data validation
Use App Studio to perform simple business logic validations that compare the value of a field against a constant value when users submit a form. You create conditions that define invalid data values so that an error message is displayed when the condition is met. The system displays an error message if users generate a value that meets the condition for an invalid value. It prevents the user from continuing the Case until the resolution of the issue.
In the following image, click the + icons to learn more about how to configure a validation condition to ensure that users enter a value greater than 100.00 in the Loan amount field:
Business logic validations are often associated with Processes in the Case Life Cycle, enabling you to validate each field instance based on distinct business logic validations. The business logic validations that define acceptable values are separate from the fields that capture data. For example, the system validates a Date of birth field when users enter the date on the field. The validation is not applied again when the field is used later during Case processing.
Multiple forms may use the same field and apply different validation conditions for each instance of the field. For example, in an HR application, HR representatives enter information in the Job history form and the New hire form. In the Job history form, an HR representative enters the start date of an employee who already works at the company. The HR representative must enter a date before the current date. In the New Hire form, an HR representative enters a start date for an employee who has not started work. The HR representative must enter a start date after the current date. By using two business logic validations, one for each business condition, you can ensure that users enter the correct dates on each form.
Check your knowledge with the following interaction:
Validation on a Stage
You can also use business logic validation on a Stage. Use business logic validation on a Stage to ensure that the application generates the correct data and that users enter the correct data or perform the appropriate actions before the Case enters a specific Stage. You configure business logic validations on a Stage in the Data Model of the Case Type, and the system triggers the validation before the Case enters the specified Stage. On a Stage entry validation, if a data value meets the condition for invalid data, the Case cannot enter the Stage, and an error message is displayed.
For example, in a mortgage application, a valid credit score must be available before the Case can enter the Underwriting Stage. The application informs the user that the credit score is invalid, and the user can verify the credit history on file or cancel the Process.
In the following image, click the + icons to read more about configuring validations in the Data Model of the Case Type:
Validation on a form
You use business logic validations on a form when you cannot predict or control the value that users enter. You configure business logic validations on a form, and the validation is triggered when users submit the form. If users submit a form that contains a value that meets the condition for invalid data, the form displays an error. The system prevents the users from continuing the Case until users submit data that passes the condition. Use validation on a form when users can perform an immediate action to resolve the invalid data, such as entering a new value in a field.
For example, assume a form contains a Date of birth field. The Field Type cannot prevent users from entering and submitting a date that is in the future. However, you can design a business logic validation to display an error if users submit a date that is in the future. The system lets users submit the form after users enter a date in the past.
In the center of the following image, slide the vertical line to View the Step Configuration to validate the Date of birth field on the left and the error message that is displayed in the form on the right:
Check your knowledge with the following interaction:
This Topic is available in the following Module:
Want to help us improve this content?