Range rules

‘Range’ rules make it possible to match against potentially large numbers of postcodes in a single line. 


A hyphen (-) character is used to separate the ‘from’ and ‘to’ sides of a range rule. In the example below, the postcode for the destination address must be between 1000 and 3000 (inclusive) in order for this range to be considered a match.

1000-3000

Valid usage

In order to be considered valid, both ‘sides’ of the range rule that you enter must match a valid postcode format for the country that the range applies to and they should both be the same format as one another.

In the example below the ‘to’ side of the range does not pass validation as it is not a format associated with the country for this range (Australia).

1000-30001

In the next example, both sides of the range are valid postcode formats for Australia but they are different from one another and therefore fail validation.

100-3000

Common use-cases

Range rules are considerably more suited to numerical or pseudo-numerical postcode formats (see postcode format types). This is because when a range rule is evaluated to see if it is a match for a given postcode, the comparison is computed numerically. In other words we ask: “Is this postcode greater than (or equal to) the ‘from’ side of the range and less than (or equal to) the ‘to’ side of the range”.

With numerical postcodes this comparison is straightforward. For pseudo-numerical postcodes, the ‘fixed’ portion of the format is dropped and the postcode is evaluated as a number. For example, given the range:

LT10000-LT50000

The ‘LT’ would be dropped on both sides of the range leaving:

10000-50000

Whilst it is possible to use a range rule for an alphanumeric postcode format you will most likely be better off using a wildcard-range rule instead as it's much clearer to see how matches are made using these rule types.

You should use a range rule to target a sequential group of numerical or pseudo-numerical postcodes.

You should avoid using ‘range’ rules when dealing with alphanumeric postcodes and opt instead for either wildcard or wildcard-range


Related articles: