Creating and Modifying Validation Constraints

The SAP Commerce Cloud Administration Cockpit enables you to create different types of constraints for Data Validation. You may also create groups of constraints to validate data with multiple constraints in one invocation.

The available constraints include:

  • Attribute constraint
  • Type constraint
  • Dynamic constraint

For example you may create an attribute String NotBlank constraint for Product type assuring that its Description attribute is provided. Depending on severity level set for this constraint, creation of any product without specified description may result in:

  • Error
  • Warning
  • Info

For details how Data Validation is integrated into the SAP Commerce Cloud Cockpit framework see Creating Products and Categories, Data Validation section .

In the SAP Commerce Cloud Administration Cockpit you can also edit both newly created and existing constraints, as well as delete them.

Creating New Constraints

To create a constraint click the Create new item button located in the top right corner of the editor area.

Figure: The SAP Commerce Cloud Administration Cockpit with available constraints.

Creating Attribute Constraints

  1. In the displayed wizard, select String NotBlank constraint.
  2. The new attribute constraint is displayed in the editor area. Click the button to choose an attribute, which you wish to validate.
  3. In the wizard choose Select an existing reference.
  4. In the displayed searching wizard you may search by different categories. Choose Product and description. Click button.
  5. You may change the ID of the new constraint.
  6. Choose the constraint severity level. The default is Error.
  7. Click button.
  8. To include the new constraint in the data validation process click the button.
  9. When the constraint is created, in the editor area the default error message, the class to validate, the composed type to validate and the qualifier are automatically completed.

Creating Type Constraints

  1. Follow the same steps as described in the Creating New Constraints section above.
  2. In the displayed wizard select Xor constraint.
  3. The new type constraint is displayed in the editor area. You may choose a type to validate in different ways:
    • Start typing and use a suggested type from a drop-down list.
    • Click the button to choose a type using the searching wizard.
  4. Specify both qualifiers for the Trigger type:
  5. Change the constraint severity level if necessary.
  6. Click button.
  7. To include the new constraint in the data validation process click the button.
  8. When the constraint is created, in the editor area the default error message and the class to validate is automatically completed.

Creating Type Constraints on a POJO

  1. Follow the same steps as described in the Creating New Constraints section above.
  2. In the displayed wizard select Xor constraint.
  3. The new type constraint is displayed in the editor area. In Other data section specify the POJO class with the whole package.
  4. Provide both qualifiers for the chosen POJO.
  5. Click button.
  6. To include the new constraint in the data validation process click the button.

Creating Dynamic Constraints

  1. Follow the same steps as described in the Creating New Constraints section above.
  2. In the displayed wizard select Dynamic constraint.
  3. Choose BeanShell as the script language and write the script body.

  4. Provide the type to be validated.
  5. Click button.
  6. To include the new constraint in the data validation process click the button.
  7. When the constraint is created, in the editor area the default error message and the class to validate is automatically completed.

See Also

Modifying Constraints

To modify a constraint, double-click a constraint in the browser area. It opens in editor area. All introduced changes are saved automatically. However, to activate the changed constrains so that they will be used by the validation engine, click the button.

Creating Constraint Groups

  1. Click the List all groups button to display all existing constraint groups. There is a default constraint group that can not be removed or modified.
  2. Click the Create new item button to create a new group.
  3. You may add member constraints to the group in a different ways:
    • Start typing and use a suggested constraint from a drop-down list.
    • Click the button to choose a type using the searching wizard. You may choose existing constraints or create new.
  4. When all member constraints are chosen, you may change the group ID and click Create button to create the new constraints group.
  5. To include the new constraint group in the data validation process click the button. The new group is then listed in the browser area.