Validation groups

Validation groups is a feature which allows you to set up validation rules for fields in the Shopping Cart app.  

A validation group contains a number of validation fields, which define rules that are applied to a field in the checkout flow.

To create a validation group:

  • Go to Settings > Ecommerce > Orders > Validation groups
  • Click New in the toolbar

This opens 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 rules, consisting of an operator and possibly a parameter, which need to return true for the field content to be considered valid
  • If two rules are created for a field, define if all or only one of the rules must validate

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.