Uniqueness validation rule
The uniqueness validation rule builder has the following properties:
Property | Description |
---|---|
attribute IDs | A list of attributes IDs that should have a unique combination of values for each product across the channel |
error message | The error message that will show up in PDX UI if two products have the same combination of values |
Code Example:
UniqueAttributeValidation validation = BusinessRuleBuilder.uniquenessValidation()
.withAttribute("GTIN")
.withErrorMessage("GTIN must be unique across all products in this channel")
.build();
This produces the following JSON output when rule is serialized:
{
"requiredAttributeIds": [
"GTIN"
],
"errorMessage": "GTIN must be unique across all products in this channel"
}
This rule then ensures that each product in the channel has a unique GTIN value.
It is possible to add multiple attribute IDs to the list of attribute IDs that are being validated, and if some of those attributes are multi valued so that they do not have a single value, but rather a list of values, then uniqueness of all combinations of values are being enforced.
Example:
Given two products in a channel:
productA = {
"BRAND": "Some Brand",
"INTERNAL IDs": [ "ABC", "DEF" ],
... // other attributes
}
productB = {
"BRAND": "Some Brand",
"INTERNAL IDs": [ "GHI", "DEF" ],
... // other attributes
}
Then it is possible to have a uniqueness validation rule targeting “BRAND” and “INTERNAL IDs” that notices that the shared combination of values:
{
"BRAND": "Some Brand",
"INTERNAL IDs": "DEF"
}
therefore violates uniqueness.
Updated over 1 year ago