Below are some detailed examples of using the rules engine.
In this example the rules engine is used to validate Stock Item Extended Properties for a match. This only works when mapping has been set up so that when orders are downloaded they automatically map to a Linnworks Inventory Items
Regex is short for Regular Expression, and is used to check text for patterns. More information can be found here & here
In this example RegEx is used to see if the post code save with the Linnworks Order matches the required format for a UK Postcode. It does not guarantee that the actual post code supplied is valid or if a courier will deliver to the location, just that the format is valid and the structure makes sense.
|
Fig 3.1 |
The example used above checks if a postcode is valid, but further RegEx could be used to determine if the postcode is for Mainland UK or not.
To do this, we can write more expressions to see if the postcodes match any known oversea postcodes. Examples of these expressions can be found below.
Postcode Area | Postcode Range | Required RegEx |
---|---|---|
Inverness |
IV1 - IV56 |
^IV([1-9]|[1-4][0-9]|5[0-6])[\s]*([\d][A-Za-z]{2})$ |
The above examples work based on the rules for particular areas. A generalised rule for UK Post Codes would normally be that the initial Group would be 2 letters, followed by 1 or 2 numbers, so ^(AANN)[\s]*([\d][A-Za-z]{2})$ where AA represents the two letters and NN is the number or range of numbers. However, this doesn't account for post Codes such as SW1Y4PH, which is a valid London Postcode. Therefore, the correct RegEx to use would be:
^[A-Z][A-Z]?[0-9][0-9]?[A-Z]?[\s]*([\d][A-Za-z]{2})$