# Enforce Address Postcode Validation

**LFS Version requirement:** v11.16 or later

The delivery address form in Limio For Salesforce validates the Postal/Zip Code field value against a Regular Expression from the Custom Metadata Type config.

The validation occurs in the Delivery Contact component, in the Delivery Postal Code field, and depends on the Country being selected.

<figure><img src="/files/OESWfmVGFCq6tLnd2jL7" alt=""><figcaption></figcaption></figure>

Because the post code validation depends on the country being selected, any given post code is considered invalid as long as country field is not populated.

<figure><img src="/files/7BNZsf4kR7gY9y9ycKyp" alt=""><figcaption></figcaption></figure>

NOTE: if the setting is left blank and no regular expression is specified, any post code is considered as valid for the country.

The form supports further customisation for adding a custom validation message specific to each country. In this case the custom message will appear as placeholder to the delivery postal code, to help the user inputting the code in a valid format from the start.

<figure><img src="/files/v1KZbn63jX9H1y8CnhNE" alt=""><figcaption></figcaption></figure>

If the format used is still invalid against the regex specified, the same validation message will appear as input field error message:

<figure><img src="/files/7IwtRz1fLLqQggY0664I" alt=""><figcaption></figcaption></figure>

In order to update the regular expression and the corresponding validation message, follow the instructions below:

1. In the Setup search box, look for the Custom Metadata Types and click 'Manage Records' on the **Region** type.<br>

   <figure><img src="/files/uisBt2ifYtusLSrbp0LI" alt=""><figcaption></figcaption></figure>
2. Find a region of interest and click 'Edit'.<br>

   <figure><img src="/files/iWHJgzej0BQWRqJ42m7G" alt=""><figcaption></figcaption></figure>
3. Find the **Address Validation** field and populate a **'zip'** property of the object inside with the relevant Regular Expression.<br>

   <figure><img src="/files/lfEtz8jAQMoGZX9LN04B" alt=""><figcaption></figcaption></figure>
4. In the same **Address Validation** filed, add (or edit) the property '**invalid\_code\_msg'** with the relevant message.<br>

   <figure><img src="/files/w5CLbzRyxQnywbSjpwfs" alt=""><figcaption></figcaption></figure>
5. Save the record.

As an example, the Address Validation can be populated as follows for United Kingdom post codes.

```
{
"posturl": "http://www.royalmail.com/postcode-finder",
"require": "ACZ",
"key": "GB",
"name": "UNITED KINGDOM",
"id": "data/GB",
"locality_name_type": "post_town",
"zipex": "EC1Y 8SY,GIR 0AA,M2 5BQ,M34 4AB,CR0 2YR,DN16 9AA,W1A 4ZZ,EC1A 1HQ,OX14 4PG,BS18 8HF,NR25 7HG,RH6 0NP,BH23 6AA,B6 5BA,SO23 9AP,PO1 3AX,BFPO 61",
"fmt": "%N%n%O%n%A%n%C%n%Z",
"zip": "GIR ?0AA|(?:(?:AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|BX|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(?:\\d[\\dA-Z]? ?\\d[ABD-HJLN-UW-Z]{2}))|BFPO ?\\d{1,4}",
"upper": "CZ",
"invalid_code_msg": "For UK use format AB1 CD2"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.limio.com/integrations/using-limio-for-salesforce/address-mandatory-fields/address-postcode-validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
