Docs‎ > ‎CA Live API Creator‎ > ‎Rules‎ > ‎

Validations

Validations are expressions that must be true for a transaction to commit.  For example, altering a Line Item may adjust the Purchase Orders amount_total, which adjusts the Customer's balance.  Such derivations are always subjected to validation checks at each level.  So, our transaction might fail due to the following contraint:

Constrain Customer.CheckCredit as balance < credit_limit with Message({Customer.balance} exceeds credit}

Failed transactions are rolled back, and a suitable exception is returned to the client.

Validations can reference all attributes of the current row, their old values, and parent columns.  Changes to parent columns referenced in child logic cascades to all children, so the validation can be rechecked.

It is a common practice for a constraint to reference derivation results, such as the example described below in Commit Validations.

Validation as Expression

Validations are typically expressed as an expression as shown below.  The expression must return a boolean, and may reference:
  • attributes
  • old values
  • parent attributes


Properties

Validation Names are defaulted by the system.   They do not have semantics.

The Error Message is the text returned to the client.  You can embed data values, signified by curly (e.g. {name}  or {balance} )brackets.

Commit Validations

You can define a validation so that it is checked only at the end of the transaction, when all the logic has been executed for all the rows in the transaction.  See the No Empty Orders example.