webCOMAND

Field Validations

Ensure field values meet specific requirements with field validations.  Field validations are checked when content is saved and approved, whether through the webCOMAND UI or APIs.  If a field is not valid, content can not be saved or approved, effectively preventing the addition of invalid content.

Some warnings are also displayed in the browser in real-time as the user makes changes in Form View.  Others may only display when a user attempts to save or approve content.

Choices Menu

Default Validations

Some types of fields, such as dates and numbers, have default validations, to ensure values can be interpreted and stored properly.  These base-level validations can not be removed, but more specific custom validations can be added.

Unique/Key Validations

The Unique/Key field option can be set to one of the following for any data type field.

  • Not Unique - The field value will not be compared to the same field value in other records of the same content type.  In other words, the value does not need to be unique.
  • Unique (most strict) - The field value will be compared to the same field value in all other records and variants of the same content type.  If any of those records or variants have the exact same value, the new record will not validate, and an error will be displayed.
  • Unique within same Collection - The field value will be compared to the same field value in all other records and variants of the same content type within the same collection.  That is, the other record is in the same Folder and/or embedded or referenced from the same field (note that records can be in multiple folders and reference fields).  If any of those records or variants have the exact same value, the new record will not validate, and an error will be displayed.
  • Unique within same Variant - The field value will be compared to the same field value in all other records with the same dimension field settings.  That is, a record with the Language dimension field set to English will be compared to all other records of the same content type with the Language dimension field set to English.  Likewise, if the Language dimension field is not set, it will be compared to all other records of the same content type with the Language dimension field not set.  If there are multiple dimension fields, all must be set/unset in exactly the same combination to be compared.  If any of those records have the exact same value, the new record will not validate, and an error will be displayed.
  • Unique within same Collection and Variant - Combines the previous two options.  That is, only records with matching dimension field settings that are within the same collection will be compared.  If any of those records have the exact same value, the new record will not validate, and an error will be displayed.

Custom Validations

The following custom validation types are available for certain field types.

Required

Ensures a value is specified.

While this is a pretty self-explanatory validation, to does means slightly different things depending on the field type.  For example, when applied to a checkbox field, it means the field must be checked.  When applied to a text field, it means at least one character must be entered.  When applied to a field with choices or a single reference, it means a selection must be made.  When it is applied to a field with multiple references, it means at least one reference must be selected.

Number Range

Ensures a number field value falls between a minimum and/or maximum number.

Character Count

Ensures a text field value contains a minimum and/or maximum number of characters.

Custom (RegEx)

Ensures a text field value matches a certain pattern, specified as a regular expression.  The regular expression must be a JavaScript compatible.

Selection Count

Ensures a reference field value contains a minimum and/or maximum number of selected items.

Add Custom Field Validations

Edit Field Appearance SidebarTo define custom field validations in Content Type Editor View:

  1. Select the desired field.
  2. Click "Advanced" in the Edit Field Sidebar.
  3. Click the "+" in upper-right of Validations.
  4. Select the desired type of validation.
  5. Enter the desired restrictions and optional message to display when the restrictions are not met.
  6. Click the check mark to the right.

Once all of the desired validations are configured, approve the content type to apply the updates.

Order Custom Field Validations

To change the order field validations are processed:

  1. Click on the left edge "grip" of a validation.
  2. Drag and drop the option to the desired place.

Edit Custom Field Validation

  1. Click the existing rule.
  2. Update the options.
  3. Press ENTER or click the check action to the right.

Delete Custom Field Validation

  1. Hover over the option with the mouse cursor.
  2. Click the delete option to the right.
More complex validations that take the value entered in other/multiple fields can be configured using cTemplate and PHP code.  For more information, see Validations.