@planning-inspectorate/dynamic-forms 2.0.2 → 2.0.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planning-inspectorate/dynamic-forms",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "This package is for building GDS forms using a configuration-based approach.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Planning-Inspectorate/dynamic-forms.git"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"commitlint": "commitlint --from=$(git cherry origin/main | head -n 1 | cut -c 3-)",
|
|
12
|
+
"commitlint": "commitlint --from=$(git rev-parse $(git cherry origin/main | head -n 1 | cut -c 3-)^1)",
|
|
13
13
|
"lint": "npx eslint .",
|
|
14
14
|
"format": "prettier --write .",
|
|
15
15
|
"format-check": "prettier --check .",
|
|
@@ -21,8 +21,8 @@ export const townCityMaxLength = 250;
|
|
|
21
21
|
export const townCityMinLength = 0;
|
|
22
22
|
export const countyMaxLength = 250;
|
|
23
23
|
export const countyMinLength = 0;
|
|
24
|
-
export const postcodeMaxLength =
|
|
25
|
-
export const postcodeMinLength =
|
|
24
|
+
export const postcodeMaxLength = 7;
|
|
25
|
+
export const postcodeMinLength = 5;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* enforces address fields are within allowed parameters
|
|
@@ -143,7 +143,7 @@ export default class AddressValidator extends BaseValidator {
|
|
|
143
143
|
return validator
|
|
144
144
|
.isLength({ min: postcodeMinLength, max: postcodeMaxLength })
|
|
145
145
|
.bail()
|
|
146
|
-
.withMessage(`Postcode must be
|
|
146
|
+
.withMessage(`Postcode must be between ${postcodeMinLength} and ${postcodeMaxLength} characters`)
|
|
147
147
|
.custom((postcode) => {
|
|
148
148
|
return validatePostcode(postcode);
|
|
149
149
|
});
|
|
@@ -6,6 +6,7 @@ import AddressValidator, {
|
|
|
6
6
|
addressLine1MaxLength,
|
|
7
7
|
addressLine2MaxLength,
|
|
8
8
|
postcodeMaxLength,
|
|
9
|
+
postcodeMinLength,
|
|
9
10
|
townCityMaxLength
|
|
10
11
|
} from './address-validator.js';
|
|
11
12
|
|
|
@@ -107,7 +108,10 @@ describe('AddressValidator', () => {
|
|
|
107
108
|
`Address line 2 must be ${addressLine2MaxLength} characters or less`
|
|
108
109
|
);
|
|
109
110
|
assert.strictEqual(errors.testField_townCity.msg, `Town or city must be ${townCityMaxLength} characters or less`);
|
|
110
|
-
assert.strictEqual(
|
|
111
|
+
assert.strictEqual(
|
|
112
|
+
errors.testField_postcode.msg,
|
|
113
|
+
`Postcode must be between ${postcodeMinLength} and ${postcodeMaxLength} characters`
|
|
114
|
+
);
|
|
111
115
|
});
|
|
112
116
|
});
|
|
113
117
|
|