validate
Validate all data marked as modified.
validate
validate/e {Entity}
validate/o {Entity}
Example: validate/e "CUSTOMER"
Qualifiers
Qualifier | Description |
---|---|
/e | Validate only the modified occurrences of Entity and its inner entities. |
/o | Validate only the current occurrence of Entity and its inner entities. |
Parameters
Entity—entity whose data is to be validated. Can be a string, or a field, variable, function, or parameter that evaluates to a string containing the entity name. If omitted, the current entity ($entname) is used.
Return Values
The values returned in $status following validate are:
Value | Meaning |
---|---|
<0 | An error occurred. $procerror contains the exact error. |
>=0 | Statement executed successfully |
Value | Error constant | Meaning |
---|---|---|
-34
|
<UGENERR_CURRENCY>
|
Changes to the active path not allowed. |
-35
|
<UGENERR_4GL_SAYS_ERROR>
|
A trigger returned a negative value in $status. |
-300
|
<UVALERR_SYNTAX>
|
An error in declarative syntax occurred. |
-303
|
<UVALERR_KEY_EMPTY>
|
A key field is empty. |
-1102
|
<UPROCERR_ENTITY>
|
The entity name is not a valid name or the entity is not painted on the component. |
Whenever one or more errors occur, the function $dataerrorcontext contains information about the exact context of the error first validation error encountered by validate; the function $procerrorcontext indicates the exact location of this error.
Use
Allowed in all component types, except self-contained Reports.
Description
The validate statement builds a list of data within the component that is marked as modified and has not previously been successfully validated. It then activates the necessary validation triggers for each modification. For example, if a modified non-key field needs to be validated, only the field- and entity-level validate triggers are activated.
As each stage of the validation process completes successfully, the corresponding validation flag ($fieldvalidation, $keyvalidation, $occvalidation) is set to 0. When the entire process completes successfully, $instancevalidation is set to 0.
Note: Validation statements (validatefield, validatekey, validateocc, and validate) activate the validation triggers such as validate and validatekey. You should therefore be careful when using these statements in validation triggers.
Used without a switch, the validate statement validates all modified data within the component. The scope of the modified data to be validated can be restricted by supplying one of the switches.
Sequence of Validation
During the validation process, the data in the component is searched in a depth-first fashion, traversing the occurrences in the component structure from top to bottom, left to right, validating occurrences of the inner entities before validating the outer occurrence. For each occurrence that needs validating, the following actions occur:
- For the primary key:
- Declarative checks and field-level validate trigger, for each field of the primary key that needs validation
- validatekey trigger, for the primary key, if the primary key needs validation
- For each candidate key:
- Declarative checks and field-level validate trigger, for each field of the candidate key that needs validation
- validatekey trigger, for the candidate key, if the
Validate property for the candidate key is
True
and the candidate key needs validation
- For each remaining field that has been
modified:
- Declarative checks
- Field-level validate trigger, if the field needs validation
- For the occurrence:
- Declarative checks
- validate trigger, if the occurrence needs validation
The extent of the activation of triggers depends on the particular validation ProcScript statements used. This is summarized in the following table:
Statement | Field-level validatetrigger activated ... | validateKey trigger activated ... | Entity-level validate trigger activated ... |
---|---|---|---|
validate
For all occurrences in the component: |
All fields that need validation | All keys that need validation | All occurrences that need validation |
validate/e
For all occurrences of the specified entity and all its inner entities: |
All fields that need validation | All keys that need validation | All occurrences that need validation |
validate/o
For the specified occurrence and all its inner entities: |
All fields that need validation | All keys that need validation | All occurrences that need validation |
validateocc
For the specified occurrence (no inner entities): |
All fields that need validation | All keys that need validation | That occurrence only |
validatekey
For the specified key: |
All key fields that need validation | That key only | — |
validatefield
For the specified field: |
That field only | — | — |
Using validate
The following example validates all modified (and non-validated) occurrences of the entity CUSTOMER, along with modified occurrences of any inner entities:
$MYENTITY$ = "CUSTOMER" validate/e "%%$MYENTITY$"