Application Express User's Guide > Using Application Builder > Editing a Page Definition > Understanding Validations
Understanding Validations |
Previous |
Next |
You can define a validation declaratively by selecting a validation method. You enter the actual validation edit check in the Validation Messages field. Be aware that if a validation fails, subsequent page processes or computations will not occur. Also remember that the validation you enter must be consistent with the validation type you selected. For more information about validation types, see online Help.
Topics:
To create a new validation:
Note: Text entered for validations may not exceed 3,950 characters. |
Navigate to the appropriate Page Definition:
Navigate to the Database Home Page.
Click the Application Builder icon.
Select an application.
Select a page.
The Page Definition appears.
Under Validations, click the Create icon.
Select a validation level. Item level validations are specific to a single item. Page level validations do not apply to any single item, but apply to an entire page.
If you selected Item level validation, select the item to be validated and click Next.
Select a validation method as described in Table: Validation Methods.
Validation Methods
Validation Method | Descriptions |
---|---|
SQL |
Compares item values to data in the database. For example, you can use a SQL validation to verify whether a last name typed into a field exists in the database. In the following Exists SQL validation, the field is named SELECT 1 FROM customers WHERE last_name = :P1_LAST_NAME |
PL/SQL |
Useful if you need complex logic to validate entered data. For example, suppose you need to create a validation for an address form that requires the user enter a province if the address is not in the United States. You could create the validation as a Function Returning Boolean, using the following PL/SQL: BEGIN IF :P1_COUNTRY = 'US' AND :P1_PROVINCE IS NULL THEN RETURN FALSE; ELSE RETURN TRUE; END IF; END; You could also create the same validation implemented as a PL/SQL Expression as follows: NOT (:P1_COUNTRY='US' AND :P1_PROVINCE IS NULL); |
Item Level Null |
Checks if an item's value in session state is null. For example, you could validate that the user enters a value in a field by creating an item validation and then selecting the validation method Item Not Null. |
Item String Comparison |
Compares the value of an item to a specific string. There are several string comparison validations that compare the value of an item to a literal string. For example, you select the validation type Item in Expression 1 is contained in Expression 2 to validate a user entry in a field against a list of values you provide. In Expression 1, enter the name of item you want to validate without a colon. For example: P1_VALUE In Expression 2, enter a string a values you want to validate against. For example: ABC/DEF/GHI |
Regular Expression |
Regular expressions provide a method to describe text patterns. Use a Regular Expression validation to perform data validation. For example, you could use the following regular expression validation to verify that a string of entered data always consists of groups of six numbers separated by commas and followed by a comma: ^([[:digit:]]{6},)+$ This regular expression would find the following entries valid:
However, the following would not be valid:
|
For SQL, PL/SQL, and Item String Comparison validations, select the type of validation you want to create and click Next.
Specify the sequence and validation name and click Next.
Depending upon the validation method, enter the validation or message text that displays if the validation fails. Click Next.
Define conditions that apply to this validation and click Create.
You can choose to have validation error messages display inline (that is, on the page where the validation is performed) or on a separate error page.
To define how a validation error message displays:
Navigate to the appropriate Page Definition:
Navigate to the Database Home Page.
Click the Application Builder icon.
Select an application.
Select a page.
The Page Definition appears.
Under Validations, select the appropriate validation.
The attributes page for the validation appears.
Scroll down to Error Message.
In Error Message, enter your error message text.
From Error message display location, select a display location.
This attribute identifies where a validation error message displays. Validation error messages can display on an error page or inline within the existing page. Inline error messages can display in a notification area (defined as part of the page template) or within the field label.
To create a hard error that stops all processing (including validations), you must display the error on an error page.
If you select Inline with Field or Inline with Field and in Notification, you need to associate an item with the error message. To associate an item with the error message, select the item from the Associated Item list.
Click Apply Changes.
You can control when and if a validation is performed under Conditions.
To create a condition for an existing validation:
Navigate to the appropriate Page Definition:
Navigate to the Database Home Page.
Click the Application Builder icon.
Select an application.
Select a page.
The Page Definition appears.
Under Validations, select the appropriate validation.
The attributes page for the validation appears.
Scroll down to Conditions.
To have a validation performed when a user clicks a particular button, make a selection from the When Button Pressed list.
Make a section from the Condition Type list.
Depending upon the selected Condition Type, enter values in the Expression attributes. The validation will be rendered or processed if the specified condition is met.
Click Apply Changes.