@financial-times/n-conversion-forms 27.0.4 → 27.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/__snapshots__/delivery-instructions.spec.js.snap +6 -6
- package/components/delivery-instructions.jsx +56 -4
- package/dist/delivery-instructions.js +33 -3
- package/helpers/index.js +1 -0
- package/helpers/supportedPostcodeExamples.js +7 -7
- package/helpers/supportedPostcodeValidators.js +37 -37
- package/helpers/supportedPostcodeValidators.spec.js +26 -0
- package/package.json +1 -1
|
@@ -72,7 +72,7 @@ exports[`DeliveryInstructions renders with a custom value 1`] = `
|
|
|
72
72
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
73
73
|
</span>
|
|
74
74
|
<span class="o-forms-title__prompt">
|
|
75
|
-
Special characters including punctuation cannot be used in the
|
|
75
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
76
76
|
</span>
|
|
77
77
|
</span>
|
|
78
78
|
<span class="o-forms-input o-forms-input--textarea">
|
|
@@ -101,7 +101,7 @@ exports[`DeliveryInstructions renders with a disabled input element 1`] = `
|
|
|
101
101
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
102
102
|
</span>
|
|
103
103
|
<span class="o-forms-title__prompt">
|
|
104
|
-
Special characters including punctuation cannot be used in the
|
|
104
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
105
105
|
</span>
|
|
106
106
|
</span>
|
|
107
107
|
<span class="o-forms-input o-forms-input--textarea">
|
|
@@ -130,7 +130,7 @@ exports[`DeliveryInstructions renders with an error 1`] = `
|
|
|
130
130
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
131
131
|
</span>
|
|
132
132
|
<span class="o-forms-title__prompt">
|
|
133
|
-
Special characters including punctuation cannot be used in the
|
|
133
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
134
134
|
</span>
|
|
135
135
|
</span>
|
|
136
136
|
<span class="o-forms-input o-forms-input--textarea o-forms-input--invalid">
|
|
@@ -158,7 +158,7 @@ exports[`DeliveryInstructions renders with default props 1`] = `
|
|
|
158
158
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
159
159
|
</span>
|
|
160
160
|
<span class="o-forms-title__prompt">
|
|
161
|
-
Special characters including punctuation cannot be used in the
|
|
161
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
162
162
|
</span>
|
|
163
163
|
</span>
|
|
164
164
|
<span class="o-forms-input o-forms-input--textarea">
|
|
@@ -186,7 +186,7 @@ exports[`DeliveryInstructions renders with maxlength 1`] = `
|
|
|
186
186
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
187
187
|
</span>
|
|
188
188
|
<span class="o-forms-title__prompt">
|
|
189
|
-
Special characters including punctuation cannot be used in the
|
|
189
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
190
190
|
</span>
|
|
191
191
|
</span>
|
|
192
192
|
<span class="o-forms-input o-forms-input--textarea">
|
|
@@ -215,7 +215,7 @@ exports[`DeliveryInstructions renders with rows 1`] = `
|
|
|
215
215
|
For newspaper delivery, we can only deliver to the ground floor, so if you live in an apartment, we’ll leave the newspaper at reception or by the entrance. We deliver in the early hours of the morning so our drivers won’t be able to contact you or ring your doorbell.
|
|
216
216
|
</span>
|
|
217
217
|
<span class="o-forms-title__prompt">
|
|
218
|
-
Special characters including punctuation cannot be used in the
|
|
218
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
219
219
|
</span>
|
|
220
220
|
</span>
|
|
221
221
|
<span class="o-forms-input o-forms-input--textarea">
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
import { identifyFTShippingZone } from '../helpers/supportedCountries';
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
const spanMessageByCountry = {
|
|
6
8
|
GBR: (
|
|
@@ -32,6 +34,57 @@ const spanMessageByCountry = {
|
|
|
32
34
|
<a href="https://help.ft.com/contact/">FT Customer Care</a>.
|
|
33
35
|
</span>
|
|
34
36
|
),
|
|
37
|
+
CEMEA_V1: (
|
|
38
|
+
<>
|
|
39
|
+
<span className="o-forms-title__prompt">
|
|
40
|
+
Newspaper delivery is restricted to ground floor addresses.
|
|
41
|
+
If you live in an apartment the newspaper will be left at reception or by the entrance.
|
|
42
|
+
Delivery is made in the early hours making it sometimes difficult to identify the right
|
|
43
|
+
delivery location or gaining access where letter boxes are inside a building.
|
|
44
|
+
</span>
|
|
45
|
+
<span className="o-forms-title__prompt">
|
|
46
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
47
|
+
</span>
|
|
48
|
+
<span className="o-forms-title__prompt">
|
|
49
|
+
If you prefer delivery to a mailbox, please either select the “PO Box” delivery option from the top of this form, or contact
|
|
50
|
+
<a href="https://help.ft.com/contact/">FT Customer Care</a>.
|
|
51
|
+
</span>
|
|
52
|
+
</>
|
|
53
|
+
),
|
|
54
|
+
CEMEA_V2: (
|
|
55
|
+
<>
|
|
56
|
+
<span className="o-forms-title__prompt">
|
|
57
|
+
Newspaper delivery is restricted to ground floor addresses.
|
|
58
|
+
If you live in an apartment the newspaper will be left at reception or by the entrance.
|
|
59
|
+
Delivery is made in the early hours making it sometimes difficult to identify the right
|
|
60
|
+
delivery location or gaining access where letter boxes are inside a building.
|
|
61
|
+
</span>
|
|
62
|
+
<span className="o-forms-title__prompt">
|
|
63
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
64
|
+
</span>
|
|
65
|
+
<span className="o-forms-title__prompt">
|
|
66
|
+
If you prefer delivery to a mailbox, please either select the “PO Box” delivery option from the top of this form, or contact
|
|
67
|
+
<a href="https://help.ft.com/contact/">FT Customer Care</a>.
|
|
68
|
+
</span>
|
|
69
|
+
</>
|
|
70
|
+
),
|
|
71
|
+
APAC: (
|
|
72
|
+
<>
|
|
73
|
+
<span className="o-forms-title__prompt">
|
|
74
|
+
Newspaper delivery is restricted to ground floor addresses.
|
|
75
|
+
If you live in an apartment the newspaper will be left at reception or by the entrance.
|
|
76
|
+
Delivery is made in the early hours making it sometimes difficult to identify the right
|
|
77
|
+
delivery location or gaining access where letter boxes are inside a building.
|
|
78
|
+
</span>
|
|
79
|
+
<span className="o-forms-title__prompt">
|
|
80
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
81
|
+
</span>
|
|
82
|
+
<span className="o-forms-title__prompt">
|
|
83
|
+
If you prefer delivery to a mailbox, please either select the “PO Box” delivery option from the top of this form, or contact
|
|
84
|
+
<a href="https://help.ft.com/contact/">FT Customer Care</a>.
|
|
85
|
+
</span>
|
|
86
|
+
</>
|
|
87
|
+
),
|
|
35
88
|
};
|
|
36
89
|
|
|
37
90
|
export function DeliveryInstructions ({
|
|
@@ -79,11 +132,10 @@ export function DeliveryInstructions ({
|
|
|
79
132
|
};
|
|
80
133
|
const deliveryInstructionsMessage = (
|
|
81
134
|
<span className="o-forms-title__prompt">
|
|
82
|
-
Special characters including punctuation cannot be used in the
|
|
83
|
-
instructions.
|
|
135
|
+
Special characters including punctuation cannot be used in the delivery instructions.
|
|
84
136
|
</span>
|
|
85
137
|
);
|
|
86
|
-
|
|
138
|
+
const FTShippingZone = identifyFTShippingZone(country);
|
|
87
139
|
return (
|
|
88
140
|
<label
|
|
89
141
|
id={fieldId}
|
|
@@ -93,7 +145,7 @@ export function DeliveryInstructions ({
|
|
|
93
145
|
>
|
|
94
146
|
<span className="o-forms-title">
|
|
95
147
|
<span className="o-forms-title__main">Delivery instructions</span>
|
|
96
|
-
{spanMessageByCountry[
|
|
148
|
+
{spanMessageByCountry[FTShippingZone]}
|
|
97
149
|
{country === 'GBR' && deliveryInstructionsMessage}
|
|
98
150
|
</span>
|
|
99
151
|
|
|
@@ -15,6 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
17
|
|
|
18
|
+
var _supportedCountries = require("../helpers/supportedCountries");
|
|
19
|
+
|
|
18
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
21
|
|
|
20
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -32,7 +34,34 @@ var spanMessageByCountry = {
|
|
|
32
34
|
className: "o-forms-title__prompt"
|
|
33
35
|
}, "Please note we cannot guarantee delivery of the newspaper to a specific location on your property, which also includes delivery to a specific floor/suite in a building. If you prefer delivery by Canada Post, please either select the \"PO Box\" delivery option from the top of this form, or contact \xA0", /*#__PURE__*/_react["default"].createElement("a", {
|
|
34
36
|
href: "https://help.ft.com/contact/"
|
|
35
|
-
}, "FT Customer Care"), ".")
|
|
37
|
+
}, "FT Customer Care"), "."),
|
|
38
|
+
CEMEA_V1: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
39
|
+
className: "o-forms-title__prompt"
|
|
40
|
+
}, "Newspaper delivery is restricted to ground floor addresses. If you live in an apartment the newspaper will be left at reception or by the entrance. Delivery is made in the early hours making it sometimes difficult to identify the right delivery location or gaining access where letter boxes are inside a building."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
41
|
+
className: "o-forms-title__prompt"
|
|
42
|
+
}, "Special characters including punctuation cannot be used in the delivery instructions."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
43
|
+
className: "o-forms-title__prompt"
|
|
44
|
+
}, "If you prefer delivery to a mailbox, please either select the \u201CPO Box\u201D delivery option from the top of this form, or contact\xA0", /*#__PURE__*/_react["default"].createElement("a", {
|
|
45
|
+
href: "https://help.ft.com/contact/"
|
|
46
|
+
}, "FT Customer Care"), ".")),
|
|
47
|
+
CEMEA_V2: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
48
|
+
className: "o-forms-title__prompt"
|
|
49
|
+
}, "Newspaper delivery is restricted to ground floor addresses. If you live in an apartment the newspaper will be left at reception or by the entrance. Delivery is made in the early hours making it sometimes difficult to identify the right delivery location or gaining access where letter boxes are inside a building."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
50
|
+
className: "o-forms-title__prompt"
|
|
51
|
+
}, "Special characters including punctuation cannot be used in the delivery instructions."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
52
|
+
className: "o-forms-title__prompt"
|
|
53
|
+
}, "If you prefer delivery to a mailbox, please either select the \u201CPO Box\u201D delivery option from the top of this form, or contact\xA0", /*#__PURE__*/_react["default"].createElement("a", {
|
|
54
|
+
href: "https://help.ft.com/contact/"
|
|
55
|
+
}, "FT Customer Care"), ".")),
|
|
56
|
+
APAC: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
57
|
+
className: "o-forms-title__prompt"
|
|
58
|
+
}, "Newspaper delivery is restricted to ground floor addresses. If you live in an apartment the newspaper will be left at reception or by the entrance. Delivery is made in the early hours making it sometimes difficult to identify the right delivery location or gaining access where letter boxes are inside a building."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
59
|
+
className: "o-forms-title__prompt"
|
|
60
|
+
}, "Special characters including punctuation cannot be used in the delivery instructions."), /*#__PURE__*/_react["default"].createElement("span", {
|
|
61
|
+
className: "o-forms-title__prompt"
|
|
62
|
+
}, "If you prefer delivery to a mailbox, please either select the \u201CPO Box\u201D delivery option from the top of this form, or contact\xA0", /*#__PURE__*/_react["default"].createElement("a", {
|
|
63
|
+
href: "https://help.ft.com/contact/"
|
|
64
|
+
}, "FT Customer Care"), "."))
|
|
36
65
|
};
|
|
37
66
|
|
|
38
67
|
function DeliveryInstructions(_ref) {
|
|
@@ -79,8 +108,9 @@ function DeliveryInstructions(_ref) {
|
|
|
79
108
|
|
|
80
109
|
var deliveryInstructionsMessage = /*#__PURE__*/_react["default"].createElement("span", {
|
|
81
110
|
className: "o-forms-title__prompt"
|
|
82
|
-
}, "Special characters including punctuation cannot be used in the
|
|
111
|
+
}, "Special characters including punctuation cannot be used in the delivery instructions.");
|
|
83
112
|
|
|
113
|
+
var FTShippingZone = (0, _supportedCountries.identifyFTShippingZone)(country);
|
|
84
114
|
return /*#__PURE__*/_react["default"].createElement("label", {
|
|
85
115
|
id: fieldId,
|
|
86
116
|
className: "o-forms-field o-forms-field--optional",
|
|
@@ -90,7 +120,7 @@ function DeliveryInstructions(_ref) {
|
|
|
90
120
|
className: "o-forms-title"
|
|
91
121
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
92
122
|
className: "o-forms-title__main"
|
|
93
|
-
}, "Delivery instructions"), spanMessageByCountry[
|
|
123
|
+
}, "Delivery instructions"), spanMessageByCountry[FTShippingZone], country === 'GBR' && deliveryInstructionsMessage), /*#__PURE__*/_react["default"].createElement("span", {
|
|
94
124
|
className: textAreaWrapperClassNames
|
|
95
125
|
}, /*#__PURE__*/_react["default"].createElement("textarea", textAreaProps)));
|
|
96
126
|
}
|
package/helpers/index.js
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = {
|
|
|
4
4
|
'cemeaV1ISO': require('./supportedCountries').cemeaV1ISO,
|
|
5
5
|
'cemeaV2ISO': require('./supportedCountries').cemeaV2ISO,
|
|
6
6
|
'apacISO': require('./supportedCountries').apacISO,
|
|
7
|
+
'identifyFTShippingZone': require('./supportedCountries').identifyFTShippingZone,
|
|
7
8
|
'countriesSupported': require('./supportedCountries').countriesSupported,
|
|
8
9
|
'countriesSupportedISO': require('./supportedCountries').countriesSupportedISO,
|
|
9
10
|
'supportedPostcodeValidators': require('./supportedPostcodeValidators').supportedPostcodeValidators,
|
|
@@ -2,27 +2,27 @@ const { flattenObj } = require('./utilities');
|
|
|
2
2
|
|
|
3
3
|
const supportedPostcodeExamples = {
|
|
4
4
|
cemeaV1: {
|
|
5
|
-
AUT: '
|
|
5
|
+
AUT: '1708',
|
|
6
6
|
ARE: '', //match anything
|
|
7
7
|
BEL: '6596',
|
|
8
8
|
BGR: '4000',
|
|
9
9
|
HRV: '10000',
|
|
10
|
-
CZE: '00
|
|
10
|
+
CZE: '122 00',
|
|
11
11
|
DNK: '1819',
|
|
12
12
|
FIN: '39500',
|
|
13
13
|
DEU: '17087',
|
|
14
14
|
GRC: '241 00',
|
|
15
15
|
HUN: '3821',
|
|
16
|
-
ISL: '
|
|
16
|
+
ISL: '149',
|
|
17
17
|
ITA: '23844',
|
|
18
|
-
LIE: '
|
|
18
|
+
LIE: '9485',
|
|
19
19
|
LTU: 'LT-12345',
|
|
20
20
|
NLD: '6971 HJ',
|
|
21
21
|
NOR: '1608',
|
|
22
22
|
POL: '43-190',
|
|
23
23
|
PRT: '2525-517',
|
|
24
24
|
QAT: '',//match anything
|
|
25
|
-
ROU: '
|
|
25
|
+
ROU: '712341',
|
|
26
26
|
RUS: '191028',
|
|
27
27
|
SVK: '98401',
|
|
28
28
|
SVN: '8263',
|
|
@@ -41,7 +41,7 @@ const supportedPostcodeExamples = {
|
|
|
41
41
|
KOR: '46500',
|
|
42
42
|
MYS: '59100',
|
|
43
43
|
PHL: '2799',
|
|
44
|
-
SGP: '
|
|
44
|
+
SGP: '584163',
|
|
45
45
|
TWN: '100',
|
|
46
46
|
THA: '10330'
|
|
47
47
|
},
|
|
@@ -54,4 +54,4 @@ const supportedPostcodeExamples = {
|
|
|
54
54
|
|
|
55
55
|
const allSupportedPostcodeExamples = flattenObj(supportedPostcodeExamples);
|
|
56
56
|
|
|
57
|
-
module.exports = { allSupportedPostcodeExamples };
|
|
57
|
+
module.exports = { allSupportedPostcodeExamples, supportedPostcodeExamples };
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
const supportedPostcodeValidators = {
|
|
2
2
|
cemeaV1: {
|
|
3
|
-
AUT:
|
|
3
|
+
AUT: /^\d{4}$/,
|
|
4
4
|
ARE: /.*$/, //match anything
|
|
5
|
-
BEL:
|
|
6
|
-
BGR:
|
|
7
|
-
HRV:
|
|
8
|
-
CZE:
|
|
9
|
-
DNK:
|
|
10
|
-
FIN:
|
|
11
|
-
DEU:
|
|
12
|
-
GRC:
|
|
13
|
-
HUN:
|
|
14
|
-
ISL:
|
|
15
|
-
ITA:
|
|
16
|
-
LIE:
|
|
17
|
-
LTU: /^[Ll][Tt][- ]{0,1}
|
|
18
|
-
NLD:
|
|
19
|
-
NOR:
|
|
20
|
-
POL:
|
|
21
|
-
PRT:
|
|
5
|
+
BEL: /^\d{4}$/,
|
|
6
|
+
BGR: /^\d{4}$/,
|
|
7
|
+
HRV: /^\d{5}$/,
|
|
8
|
+
CZE: /^\d{3}[ ]?\d{2}$/,
|
|
9
|
+
DNK: /^\d{4}$/,
|
|
10
|
+
FIN: /^\d{5}$/,
|
|
11
|
+
DEU: /^\d{5}$/,
|
|
12
|
+
GRC: /^\d{3}[ ]?\d{2}$/,
|
|
13
|
+
HUN: /^\d{4}$/,
|
|
14
|
+
ISL: /^\d{3}$/,
|
|
15
|
+
ITA: /^\d{5}$/,
|
|
16
|
+
LIE: /^(948[5-9])|(949[0-7])$/,
|
|
17
|
+
LTU: /^[Ll][Tt][- ]{0,1}\d{5}$/,
|
|
18
|
+
NLD: /\d{4}\s{0,1}[A-Za-z]{2}$/,
|
|
19
|
+
NOR: /^\d{4}$/,
|
|
20
|
+
POL: /^\d{2}-\d{3}$/,
|
|
21
|
+
PRT: /^\d{4}([\-]\d{3})?$/,
|
|
22
22
|
QAT: /.*$/,//match anything
|
|
23
|
-
ROU:
|
|
24
|
-
RUS:
|
|
25
|
-
SVK:
|
|
26
|
-
SVN:
|
|
27
|
-
ZAF:
|
|
28
|
-
ESP:
|
|
29
|
-
SWE:
|
|
30
|
-
CHE:
|
|
23
|
+
ROU: /^\d{6}$/,
|
|
24
|
+
RUS: /^\d{6}$/,
|
|
25
|
+
SVK: /^\d{3}[ ]?\d{2}$/,
|
|
26
|
+
SVN: /^\d{4}$/,
|
|
27
|
+
ZAF: /^\d{4}$/,
|
|
28
|
+
ESP: /^\d{5}$/,
|
|
29
|
+
SWE: /^\d{3}[ ]?\d{2}$/,
|
|
30
|
+
CHE: /^\d{4}$/
|
|
31
31
|
},
|
|
32
|
-
cemeaV2: { FRA: /^[0-9]{5}$/, LUX:
|
|
32
|
+
cemeaV2: { FRA: /^[0-9]{5}$/, LUX: /^\d{4}$/, MCO: /^980\d{2}$/ },
|
|
33
33
|
apac: {
|
|
34
|
-
CHN:
|
|
34
|
+
CHN: /^\d{6}$/,
|
|
35
35
|
HKG: /.*$/, //match anything
|
|
36
|
-
IND:
|
|
37
|
-
IDN:
|
|
38
|
-
JPN:
|
|
39
|
-
KOR:
|
|
40
|
-
MYS:
|
|
41
|
-
PHL:
|
|
42
|
-
SGP:
|
|
43
|
-
TWN:
|
|
44
|
-
THA:
|
|
36
|
+
IND: /^\d{6}$/,
|
|
37
|
+
IDN: /^\d{5}$/,
|
|
38
|
+
JPN: /^\d{3}-\d{4}$/,
|
|
39
|
+
KOR: /^\d{5}$/,
|
|
40
|
+
MYS: /^\d{5}$/,
|
|
41
|
+
PHL: /^\d{4}$/,
|
|
42
|
+
SGP: /^\d{6}$/,
|
|
43
|
+
TWN: /^\d{3}(\d{2})?$/,
|
|
44
|
+
THA: /^\d{5}$/
|
|
45
45
|
},
|
|
46
46
|
other: {
|
|
47
47
|
GBR: /^[A-Za-z]{1,2}[0-9][0-9A-Za-z]?[\s-]?[0-9][A-Za-z]{2}$/,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { supportedPostcodeValidators } = require('./supportedPostcodeValidators');
|
|
2
|
+
const { supportedPostcodeExamples } = require('./supportedPostcodeExamples');
|
|
3
|
+
|
|
4
|
+
describe('supportedPostcodeValidators', () => {
|
|
5
|
+
it('should validate every cemeaV1 supportedPostcodeExamples', () => {
|
|
6
|
+
const cemeaV1PostcodeCountryCodes = Object.keys(supportedPostcodeExamples.cemeaV1);
|
|
7
|
+
|
|
8
|
+
for ( const cemeaV1PostcodeCountryCode of cemeaV1PostcodeCountryCodes ) {
|
|
9
|
+
expect(supportedPostcodeValidators.cemeaV1[cemeaV1PostcodeCountryCode].test(supportedPostcodeExamples.cemeaV1[cemeaV1PostcodeCountryCode])).toBe(true);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
it('should validate every cemeaV2 supportedPostcodeExamples', () => {
|
|
13
|
+
const cemeaV2PostcodeCountryCodes = Object.keys(supportedPostcodeExamples.cemeaV2);
|
|
14
|
+
|
|
15
|
+
for ( const cemeaV2PostcodeCountryCode of cemeaV2PostcodeCountryCodes ) {
|
|
16
|
+
expect(supportedPostcodeValidators.cemeaV2[cemeaV2PostcodeCountryCode].test(supportedPostcodeExamples.cemeaV2[cemeaV2PostcodeCountryCode])).toBe(true);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
it('should validate every apac supportedPostcodeExamples', () => {
|
|
20
|
+
const apacPostcodeCountryCodes = Object.keys(supportedPostcodeExamples.apac);
|
|
21
|
+
|
|
22
|
+
for ( const apacPostcodeCountryCode of apacPostcodeCountryCodes ) {
|
|
23
|
+
expect(supportedPostcodeValidators.apac[apacPostcodeCountryCode].test(supportedPostcodeExamples.apac[apacPostcodeCountryCode])).toBe(true);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.7",
|
|
4
4
|
"description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|