Change Detection and Validation
Hii Retail provides advanced change detection and validation capabilities to ensure data integrity and compliance throughout the product and price lifecycle. The main services in this area are:
- Change Detection
- Validation Engine
- Approval
- Print Scheduling
- Distribution
Together, these services enable you to:
- Identify and output changes on an entity, including previous values
- Validate changes against customer-specific rules
- Hold back changes that violate any rules
- Set aside changes requiring manual intervention before distribution, such as:
- Printing paper labels or posters
- Manual approval in a UI
- Trigger custom actions and warnings
- Distribute data to downstream services when all validations pass
Change Detection Service
The Change Detection service tracks the current state of any entity (e.g., Item, Price Specification, Item Identifier). When an update for the same id is received, it identifies what has changed and produces change events. These events are stored and can be used by UIs to display all changes for individual stores. They also serve as input for the Validation Engine.
Each change event contains a list of properties that have changed since the entity was last updated.
For more details, see the Changes Query API.
Validation Engine
The Validation Engine listens for all change events and determines if any field changes require validation. If validation is needed, it executes all applicable rules for the changed properties and produces a Validation Result.
The Validation Result is then used by the Distribution service to determine if the content is ready for downstream consumption.
How Validation Works
The Validation Engine requires defined rules to operate. If no rules exist for the changes in the event, or if none are violated, the Validation Result is valid and instructs the Distribution service to allow the change. If rules are violated, the Validation Result will include details for each violated rule.
Validation Rules can be of several types and apply different checks to the changed data. See more about Validation Rules in the API documentation.
Key properties of a Validation Rule include name, entityType, fieldName, ruleType, ruleValue, and severity.
Rule Types
The rule type defines the functional area for the rule. Possible values:
LABEL_RELEVANCE: Determines if the change should trigger label printing (relevant for stores using paper labels or posters).VALIDATION: Used for content validation according to custom preferences. Can be coupled with anactionto trigger alerts in your system or Hii Retail.MANUAL_APPROVAL: Stops the change from being distributed, regardless ofseverity. Used to hold changes until manual approval is given. See Approval.ACTION: Triggers actions without restricting the change. Recommended to setseveritytoACTIONas well.
Rule Values
Rule Values define the validation logic that is applied to a field change.
Each rule instructs the system how to validate newValue (and in some cases previousValue) according to a specific logical condition.
Allowed values (enum):
HAS_CHANGED: This rule checks whethernewValueis different frompreviousValue.
Violated when:
- newValue ≠ previousValue
- One value is null and the other is not
- Arrays differ in any element or order
Examples
| previousValue | newValue | Result |
|---|---|---|
"red" | "blue" | ❌ Violated |
10 | 10 | ✔ Pass |
null | "x" | ❌ Violated |
[1,2] | [1,2,3] | ❌ Violated |
MUST_HAVE_VALUE: This rule ensures that a specific field must contain a value.
Violated when:
- Single:
null - Array:
nullor empty ([])
Examples
| newValue | Result |
|---|---|
"x" | ✔ Pass |
null | ❌ Violated |
[] | ❌ Violated |
MUST_BE_INT: This rule ensures that thenewValuefield contains a value and that the value can be converted to an integer.
Violated when:
- Value is null
- Not integer-convertible
- Any array item is invalid
Examples
| newValue | Result |
|---|---|
"42" | ✔ Pass |
"12.5" | ❌ Violated |
"abc" | ❌ Violated |
["1","2","x"] | ❌ Violated |
MUST_BE_BOOLEAN: This rule ensures that thenewValuefield contains a value (not null/empty) and that the value can be interpreted as a boolean.
Violated when:
- Null
- Not "true" or "false"
- Any invalid array element
Examples
| newValue | Result |
|---|---|
"true" | ✔ Pass |
"FALSE" | ✔ Pass |
"1" | ✔ Pass |
0 | ✔ Pass |
"yes" | ❌ Violated |
["true","x"] |