webCOMAND

Validations

There are many ways to validate objects and forms in webCOMAND.

Object and Content Validation

Validation ensures that only valid field values can be approved or saved.

NOTE: Invalid field values can be stored to allow invalid working copy versions of content before they are approved or saved.

When an object or content is approved or saved in webCOMAND or via API methods, the validations will be processed in the following order.

  • Model Validate Method - If a content type model defines a validate() method, object and content validation will be performed in PHP code.  If any errors are logged, validation will fail.  If the Validate template returns false, the validation process will end (subsequent steps below will not happen).  Validation will only fail if an error is logged before Validate template returns (even if it returns false).
  • Content Type Validate Template - If a content type model validate() method is not defined and Validate template is defined, object and content validation will be performed in cTemplate code.  If any errors are logged, validation will fail.  If the Validate template returns false, the validation process will end (subsequent steps below will not happen).  Validation will only fail if an error is logged before Validate template returns (even if it returns false).
  • Content Type Field Types - Content type fields of certain data types, such as a Number or Date, will be automatically validated based on their data type.  Additional validation rules (see below) can also be applied to further restrict values.
  • Content Type Field Validations - An optional list of regular expressions can be applied to a field value as values are entered in Form View, when Approved or Saved in Form View and when objects and content are approved, saved and stored through the API.

Form Validation

In addition to the repository object and content validation listed above, general-purpose web form validation is also supported through the following classes in the PHP API io_comand_web package.

  • validate - Prepare and validate HTML form submission values.
  • request - The request::update() method indirectly apply object and content validations when the write option is set to 'approve' or 'save'.
  • form - The form::update() method indirectly apply object and content validations when the write option is set to 'approve' or 'save'.