Validation

The purpose of Validation is to increase data governance by enabling business rules at feature level. Business rules are enforced via all user interfaces and via import. Invalid data is highlighted in the grid and in other user interfaces, highlighted yellow for violating soft rules and highlighted red for violating hard rules.

 

Feature types and feature settings

A business rule is an extended rule on a feature that limits the values users can set beyond what the feature type defines. An example could be to allow only 50 characters in a string feature (where standard is 255 characters).

Feature types

It is possible to set business rules on these feature types:

  • Number

  • String

  • Text

Feature settings

Setting business rules also depends on certain feature settings:

Feature setting

Comment

Localizable

One rule set and enforced for all languages (no language specific rules)

Inheritable

Business rule is enforced at level where value is set

Formula

Business rules can’t be set on formula features

Allow Multiple

Business rule enforced for each value; if one value is invalid, the entire value set is considered invalid

Selectable

Business rule is enforced on base value for items; no validation is done when item is selected as value

Remote (“blue fields”)

Business rules can’t be set on remote features

Rich text

Business rules can’t be set on rich text features

Identity inheritance[1]

Specific business rules can’t be set on identity inherited features; instead, they will automatically inherit the rule from their parent feature


[1] Identity inheritance is when a selectable feature inherits its value list from a parent feature.

Setting business rules

Business rules are set and managed at feature definition level on a new Validation tab. This section explains how rules can be set.

 

Rule Type

Three rule types can be used:

Rule Type

Comment

[blank]

Business rule not set

RegEx

Regular expression, see examples below

Number

Only available for number features; allows you to set a number range without using regular expression

RexEx (item base value)

Same as RegEx but only available for selectable features; values are only validated at item level (base value)

Number (item base value)

Same as Number but only available for selectable number features; values are only validated at item level (base value)

The rule area changes according to selected rule type.

Business rule

Business rule can be defined in two different ways. These are explained below.

Regular expression

Wikipedia defines a regular expression like this:

A regular expression is a sequence of characters that define a search pattern. Usually this pattern is used by string searching algorithms for "find" or "find and replace" operations on strings, or for input validation. It is a technique that developed in theoretical computer science and formal language theory.

What is relevant in our case is how to write a regular expression to validate a text (or a number). The Perfion interface does not offer any help with this, so here are some relevant examples. These can all be copied directly into the Expression box in the rule area or modified according to your needs.

Expresssion

Validation

^(?=.{1,35}$).*

String length must be between 1 and 35 characters

^[a-zA-Z_ ]*$

Only a-z, A-Z, _ and space allowed

^[0-9]{8,10}$

Only 0-9 allowed and length must be 8-10 characters

(Product|product)

 

String must contain the word Product or product

(AB|CD)[0-9]{2}

String must start with AB or CD followed by two digits between 0 and 9

Number

With Number selected as Rule Type it is possible to define a number range for values to match. In this example value must be greater than 0 and less than or equal to 100:

 

Comments:

  • Operators can be <, <=, >, >=, =, != (not equal to)

  • Value 1 and 2 can be integers, positive/negative and decimals.

  • One or two operators can be set according to needs

NOTE: If two contradictory operators are set (e.g. <50 and >100) all values are considered invalid.

Enforcement

Two options exist on all validations: 

Enforcement

How it works

Reject illegal values

Invalid values are never accepted. User is informed about rule and instructed to change value.

 

From now on referred to as hard validation.

Allow illegal values but warn user before saving

Invalid values are accepted but user is informed about rule and asked to confirm before save.

 

From now on referred to as soft validation.

Help text

The existing Help text is optional, but important when defining a rule. Best practice is to write a help text that informs users about the rule.

The help text is shown to users throughout the system when they try to create invalid values.

Enforcing business rules

This section explains how enforcement is handled in all interfaces.

General principles

These general principles apply for rule validation:

  • Empty cells are never validated. These are per default valid.

  • Cells with (old[1]) hard invalid values are marked red. Cells with soft invalid values are marked yellow.

  • Validation is done at individual feature level. It has no relevance if red or yellow values exist on other features for same item

  • Multi-value features turn red or yellow if at least one value is invalid. Each value is evaluated individually in multi-value control

  • Selectable features are only validated at item base value level. Please refer to next section.

Selectable features

When a business rule is defined for a selectable feature (e.g. Color), enforcement is only done at item base value level. In this example Color has a business rule of max 10 characters and user try to create Ocean deep blue. This is rejected.


[1] Normally it it not possible to create hard invalid values. However, if a business rule is applied to a feature that has values (allowed), some of these values may be invalid.

 

In the same example Color contains old hard invalid value (Milano Sand and Piano Black). Even though these are invalid they can still be assigned to products as values and they are not marked as invalid in product grid:

 

This is a deliberate design decision because violations should not be corrected at product level. They should be corrected at selectable item level and thus automatically corrected for all products.

Grid

When user tries to create an invalid value in grid, an alert is shown. User must react to alert before moving on. The alert contains the feature’s help text and information about the rule violation. User has different options depending on whether it’s a hard or soft rule:

Notes:

  • Enforcement is also done when copy/pasting values

  • Enforcement is also done when doing mass updates (CTRL+Enter)

Item editor

When user tries to create an invalid value in item editor, an alert is shown (identical to grid). User must react to alert before moving on.

Notes:

  • Enforcement is done when a new value is entered in a single cell (immediate response to violations).

  • No validation is done when the item editor is exited (Save & Close or Save). This ensures that new values can be saved to an item even though old invalid values exist.

Copy items, children and relations

The Perfion copy function does not enforces rules, both hard invalid values and soft invalid values will be copied.

Replace

“Replace”-value is validated against business rule of feature before replace is executed. Enforcement follows same rules as above.

Compare

Compare follows same enforcement principles as item editor. Enforcement is done at feature level and when values are copied left-right.

Import

General principles

These general principles apply to all imports:

  • If the source file contains hard invalid values the import is rejected, and the user is informed about reason(s).

  • If the source file contains soft invalid values (and no hard invalid values) the import proceeds as normal. The log shows list of imported soft illegal values.

Explicit values

Validation of explicit values is always enforced in the Perfion importer.

Selectable values

The import operates differently depending on Selectable feature validation setting:

  • If import is run with validation of selectable features (= new selectable items cannot be created), selectable features’ business rules are ignored. User can assign all existing selectable values to items.

  • If import is run without validation of selectable features (= new selectable items can be created), new selectable values are validated against the feature’s business rules. If a new selectable value does not comply with business rule the import is rejected. All existing selectable values can be assigned to items; these will not be validated.

Import examples

In this example import is rejected because user tries to import hard invalid explicit values (Weight > 2000 or Weight < 0):

 

In this example import is completed but user is informed about imported soft invalid values (ItemName: < and > are not allowed):

In this example import is run without validation of selectable features (= new selectable items can be created). Source file contain a new color that violates hard business rule and import is rejected:

In this example import is run with validation of selectable features (= new selectable items cannot be created). Source file contain a new color that complies with business rule but import is still rejected because creation of new colors is not allowed: