Validation groups

Validation Groups is a feature which makes it possible to define validation rules for groups of fields. The validation group is then applied to a Shopping Cart app, and when a customer attempts to proceed to the checkout step the values of fields with validation are tested against the validation rules - if a field does not validate you return to the previous step.

To create a validation group:

  • Go to Settings > Ecommerce > Orders > Validation groups
  • Click New in the toolbar to open the Edit view (Figure 1.1).
Figure 1.1 Creating a validation group

From here, you can:

  • Name the validation group
  • Add fields (standard order fields, custom order fields, and custom order line fields)
  • Define one or more validation rules consisting of an operator and possibly a parameter
  • If two rules are created for the same field, you must define if all or only one of the rules must validate

Please note that the field Disable validation if all fields are empty is intended for debugging scenarios only and should be unchecked on live solutions.

The operators available to you are:

Operator

Description

Required

Checks that the field is not empty

Contains/Does not contain

Checks for the presence/absence of a specific value

Equals/Does not equal

Checks the field for an exact value (and either approves or rejects it)

Is integer/Is numeric

Checks that the field contains an integer (whole numbers) or is numeric (whole numbers and decimals)

Minimum length/Maximum length

Checks the minimum or maximum length of a field value (in characters)

Is less/greater than

Checks against a minimum or maximum value. Works for both numbers and alphanumeric characters

Is valid email

Checks if the value is a valid email address

Regular expression

Allows you to enter a regular expression and check the field value against that. This allows you to check for a variety of formats, e.g. postal codes, phone numbers, and so forth.


For more details in regular expressions, please see .NET’s rules for regular expressions.

Localizing validation group names

Validation group names can be localized. Create a validation group in the default language, then change to another language using the language selector in the toolbar, and enter a name for the group in that language. Don’t forget to save the localized name.

Read more about working with internationalization here.