Skip to main content

Rule Definition Examples

This section provides examples of Duplex Sync rule definitions that follow the best practices for formatting and structure. Each example contrasts a poorly formatted rule with a well-structured one.

Example 1: Simple Conditional Ruleโ€‹

  • โŒ "If 'Are Batteries Required' (211) = TRUE, then 'Are Batteries Included' (210) SHALL be given"

  • โœ… IF 'areBatteriesRequired' (211) equals 'TRUE', THEN 'areBatteriesIncluded' (210) SHALL be indicated.

Example 2: Complex Conditional Rule and Attribute Referenceโ€‹

  • โŒ "If tradeItemUnitDescriptorCode <> PALLET and isTradeItemADespatchUnit = TRUE, and the actual unit is itself not a child of any further packaging, then nonGTINLogisticsUnitInformation/grossWeight SHALL be indicated, if one of the following GPC Brick codes have been choosen."

  • โœ… IF 'tradeItemUnitDescriptorCode' (3074) is not equal to 'PALLET' AND 'isTradeItemADespatchUnit' (3062) equals 'TRUE' AND the trade item is the highest level in its hierarchy, THEN 'nonGTINLogisticsUnitInformation/grossWeight' (1201) SHALL be indicated.

Example 3: GPC-Based Ruleโ€‹

  • โŒ "Because of the chosen GPC Brick Code, the attributes 'Target Consumer Age' and 'Target Consumer Age Language' must be filled in. The GPC Brick Code chosen is one of the following:"

  • โœ… IF the gpcCategoryCode (3122) is in (10000029, 10000030 OR 10000031), THEN 'targetConsumerAge' (1105) AND 'targetConsumerAgeLanguage' (1106) SHALL be indicated.

Example 4: Attribute Relationship Ruleโ€‹

  • โŒ "If the attribute isPackagingMarkedWithIngredients = TRUE, then the attributes ingredientStatement must be indicated at least with 'ingredientStatement/@languageCode' set to ""da""."

  • โœ… IF 'isPackagingMarkedWithIngredients' (1043) equals 'TRUE', THEN an instance of 'ingredientStatement' (816) with languageCode 'da' SHALL be indicated.

Example 5: Hierarchical Ruleโ€‹

  • โŒ "The attribute 'isPackagingMarkedReturnable' SHALL be filled in on every hierarchy level, if one of the following GPC codes is indicated."

  • โœ… IF the gpcCategoryCode (3122) is in (10000029, 10000030 OR 10000031), THEN 'isPackagingMarkedReturnable' (1833) SHALL be indicated on EVERY level of the trade item hierarchy.

Example 6: Code List Value Ruleโ€‹

  • โŒ "dangerousSubstanceInformationModule/dangerousSubstanceInformation/dangerousSubstanceProperties/riskPhraseCode must have a value from the pre-defined RiskPhraseCodeList."

  • โœ… 'riskPhraseCode' (3745) SHALL have a value from the 'RiskPhraseCodeList'.

Example 7: Rule with Numeric Constraintsโ€‹

  • โŒ "The attribute 'minimumTradeItemLifespanFromTimeOfArrival' shall not contain more than 4 numeric characters."

  • โœ… 'minimumTradeItemLifespanFromTimeOfArrival' (3479) SHALL be a numeric value with no more than 4 digits.

Example 8: Measurement Unit Ruleโ€‹

  • โŒ "If targetMarketCountryCode equals 208 (Denmark) and nutrientTypeCode is equal to ""FAT"" and then quantityContained@measurementUnitCode shall equal to ""GRM"" in the same instance of the class nutrientDetail."

  • โœ… IF 'targetMarketCountryCode' (3556) equals '208' (Denmark) AND 'nutrientTypeCode' (4048) equals 'FAT', THEN 'quantityContained' (4049) measurementUnitCode SHALL equal 'GRM'.

Example 9: Complex Mathematical Validationโ€‹

  • โŒ "Height must be calculated correctly based on layer information"

  • โœ… IF (isTradeItemPackedIrregularly equals 'false' or is not used) AND trade item is at top level AND layerHeight is used AND nestingIncrement is not used, THEN tradeItemMeasurements/height SHALL equal or be greater than ((layerHeight x quantityOfCompleteLayersContainedInATradeItem) + platform height).

Example 10: GTIN Validation Ruleโ€‹

  • โŒ "EAN_8 GTINs must start with correct prefix"

  • โœ… IF dataCarrierTypeCode equals 'EAN_8', THEN the first six digits of the tradeItem/GTIN SHALL equal '000000'.

Example 11: Attribute Presence Validationโ€‹

  • โŒ "Weight is required for dispatch units that are not non-physical"

  • โœ… IF isTradeItemADespatchUnit equals 'true' AND (isTradeItemNonPhysical equals 'false' or is not used), THEN grossWeight SHALL be greater than '0'.

Example 12: Multiple Language Requirementsโ€‹

  • โŒ "Product names must be provided in local language"

  • โœ… IF targetMarketCountryCode equals '208' (Denmark), THEN regulatedProductName (3314) with languageCode 'da' SHALL be used.

Example 13: Grouped Attribute Validationโ€‹

  • โŒ "Temperature range must be complete when specified"

  • โœ… IF minimumTemperature is used, THEN maximumTemperature SHALL also be used with the same measurementUnitCode.

Example 14: Iteration Constraintโ€‹

  • โŒ "Don't provide too many ingredient statements"

  • โœ… A maximum of 3 instances of ingredientStatement SHALL be provided per languageCode.

Example 15: Context-Specific Ruleโ€‹

  • โŒ "Consumer units need availability dates"

  • โœ… IF isTradeItemAConsumerUnit (3066) equals 'true' AND tradeItemUnitDescriptorCode (3074) equals 'BASE_UNIT_OR_EACH', THEN consumerFirstAvailabilityDateTime (3096) SHALL be used.

Refine Your Own Rulesโ€‹

Now that you've seen the best practices in action, try refining your own rule definitions with our AI-powered tool. This tool will help you apply all the guidelines from this documentation to your own rules.

Go to the Rule Refiner