Address rules
Address rules are objects that contain a list of requirements for matching an address in order to be able to use this service.
The address rules are used for the regions_from
and regions_to
attributes on the service
resource.
They determine where a service can ship to and from, so if a service for instance can ship to the United Kingdom the value of the country_code
will be GB
.
Attributes
Attribute |
Type |
Description |
Required |
---|---|---|---|
country_code |
string |
The country code to match in order to be accepted |
✓ |
state_code |
string |
The state code to match in order to be accepted |
|
postal_code |
string |
The postal codes to match in order to be accepted, presented as a regular expression |
Example
{
"country_code": "GB",
"postal_code": "^((GY|JE).*|TR2[1-5]) ?[0-9]{1}[A-Z]{2}$"
}
Note
The regular expression in the example will match all postal codes for the Channel Islands region, by matching UK postal codes starting with GY or JE or TR21 until TR25.
Warning
Instead of fetching all services and using local functions to filter on the postal_code
regex, you should use the address filters when calling the GET /services endpoint.