The Postal Code Field subcomponent can only be used within the Form component.
The Postal Code Field subcomponent allows for collection of a customers postal code, which can be used to store or update the postal code in their billing address. It can be used as part of an acquisition flow, or within self-service.
The key difference between this standalone postal code field and the Address Fields subcomponent is that this Postal Code Field support the use of built in, country specific, validation rules.
Built in Validation
If no no regex is specified in the Validation regular expression and Disable standard validation rules is toggle off, then this component will utilise the country specific regex rules.
The country specific regex rules are pulled from Limio's address metadata file, and allows for stricter validation on this field. The table below explains in detail the regex patterns in the address metadata.
Regex patterns included:
Country | Pattern | Matches | Example matches |
Australia India New Zealand |
\d{4} |
exactly four digits in a row | 1234 |
Brazil | \\d{5}-?\\d{3} |
five-digit number, followed by an optional hyphen, and then three more digits |
|
Canada | [ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z] ?\\d[ABCEGHJ-NPRSTV-Z]\\d |
Canadian post code format |
|
Great Britain |
|
the various formats of UK postal codes, including Gibraltar and military addresses (BFPO) |
|
Italy Mexico Malaysia |
\d{5} |
exactly five digits in a row | 12345 |
Japan | \d{3}-?\\d{4} |
three digits, an optional hyphen, and then four digits |
|
United States | (\\d{5})(?:[ \\-](\\d{4})) |
matches both standard ZIP codes and ZIP+4 codes in the US. |
|
All other countries | [A-Z0-9][A-Z0-9\- ]*[A-Z0-9] |
a mixture of any number, letter with hyphens and spaces allowed in between |
|
Component Props
id
|
Label
|
Type
|
Required
|
Default
|
Further Info
|
---|---|---|---|---|---|
name
|
Name
|
boolean |
✅ |
billingDetails.postalCode
|
This determines how the field is sent on the order payload. |
label
|
Label
|
string | ✅ |
{{zip_name_type}}
|
This is the field label visible to to the customer. If "{{zip_name_type}}' is used, the label will be dynamic dependent on country selected. |
toolTipMessage
|
Tooltip message
|
string | "" | If a value is entered here, a tooltip will appear next to this field, with the value in the message. | |
hidden
|
Hidden
|
boolean | false | Determines whether the field is visible to the user or not. | |
disabled
|
Disabled
|
boolean | false | Determines whether the user can type in this field or not. | |
required
|
Required
|
boolean | false | Determines whether the this field is required or not. | |
regex
|
Validation regular expression
|
string | "" | A regular expression pattern that the input value must match | |
invalidMessage
|
Invalid message
|
string | "" | The error message to display when the input value is invalid, if the field is required. | |
col
|
Column Size
|
12 | Sets the width of the input. Ranging from 1 - 6 where 6 is the max. | ||
fieldClassName
|
Class Name
|
string | "" | A class name can be added, if extra styling is needed which should target this subcomponent. | |
disableBuiltinValidation
|
Disable standard validation rules
|
boolean | false | Set to true, if you do not wish to utilise the country specific regex rules. |
Known Limitations:
Currently this component is only used to store/amend the billing details, and does not yet support the delivery details.
Comments
0 comments
Please sign in to leave a comment.