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.

Screenshot_2022-09-02_at_10.10.22.png

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

Screenshot_2022-09-02_at_10.15.26.png

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.

mceclip0.png

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

mceclip1.png

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. image__3_.png

  2. Find a region of interest and click 'Edit'. image__4_.png

  3. Find the Address Validation field and populate a 'zip' property of the object inside with the relevant Regular Expression image__5_.png

  4. In the same Address Validation filed, add (or edit) the property 'invalid_code_msg' with the relevant messagemceclip2.png

  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" }

Last updated

Was this helpful?