Skip to content

Product validators

Product validators are a powerful tool for maintaining the quality of product data. They allow for the creation of custom validation rules, ensuring that changes to product attribute values cannot be saved unless they comply with these rules.

Running product validators

Product validators are automatically run in specific scenarios and only if the validator is attached to a category marked as a product's primary category. In that case, the following scenarios run the respective product validator:

  • When saving changes to a product using either the product details page or mass edit
  • When importing through the PIM user interface
  • When importing through the PIM public API (both in merge mode and overwrite mode)

Product validators are not run/bypassed in the following scenarios:

  • When using the BulkEnrichProducts bulk operation on a product
  • When using the EnrichProduct bulk operation on a product
  • When publishing a product
  • When setting/changing a product's primary category
  • When attaching a product validator to a product's primary category

Product validator core concepts

When creating product validators, there are a couple of core concepts to understand:

  • Groups
  • Rules
  • Conditions

Example of a product validator as shown in the editor

Example of a product validator as shown in the editor. The validator contains two groups and two rules, of which one contains conditions.

Groups

Product validators consist of groups, which are logical units containing validation rules. Each group has a logical AND or OR operator, which determines how the rules within the group should be interpreted.

A group that uses the logical operator AND yields a positive validation result if all of the validation rules within the group are valid. A group using the logical operator OR yields a positive validation result if at least one of the validation rules within the group is valid.

Groups can be nested within other groups, which allows for creating more complex validation logic.

Rules

Rules are the actual validation rules that define the criteria which a product should match in order to be marked as valid. A rule consists of the following elements:

  • The attribute to validate
  • A validation criterion
  • Optionally: the attribute field to validate
  • Optionally: the segment to validate

The rule's validation criterion can be built up in several ways, depending on the complexity of the criterion. Some examples of validation rules with different types of criteria:

  • The Value field of required attribute Description must not have a value
  • The attribute Brand is required
  • The Value field of optional attribute Color must be Blue

Conditions

Conditions can be used for validation rules that only should be activated in specific cases. This makes it possible to configure validation rules for specific attributes, that depend on the state of other attributes. Multiple conditions can be applied to a single validation rule, which are applied in the order in which they were added. All conditions must resolve to true, before the validation rule they belong to is activated.

Conditions use the same semantic format as rules, consisting of the following elements:

  • The attribute to base the condition on
  • A condition criterion
  • Optionally: the attribute field to base the condition on
  • Optionally: the segment to base the condition on

Note

Conditions cannot be edited after they have been created, but they can be deleted so they no longer apply to the validation rule, and a new condition can be created if needed.