@dwp/govuk-casa 8.0.0 → 8.0.1
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/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### [8.0.1](https://github.com/dwp/govuk-casa/compare/8.0.0...8.0.1) (2022-01-12)
|
|
6
|
+
|
|
7
|
+
## [8.0.0](https://github.com/dwp/govuk-casa/compare/7.0.8...8.0.0) (2021-12-21)
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
### ⚠ BREAKING CHANGES
|
|
@@ -10,8 +12,6 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
10
12
|
* The framework has been rewritten. Refer to
|
|
11
13
|
docs/migration-guides/MIGRATION_7.x-8.x.md for more details.
|
|
12
14
|
|
|
13
|
-
Signed-off-by: james.gauld <james.gauld@engineering.digital.dwp.gov.uk>
|
|
14
|
-
|
|
15
15
|
* rewrite framework ([48c44ec](https://gitlab.com/dwp/engineering/capture-and-submit-application/govuk-casa/commit/48c44ec78d9a93eb736e74f7b23b62b0898a1e1c))
|
|
16
16
|
|
|
17
17
|
### [7.0.8](https://github.com/dwp/govuk-casa/compare/7.0.7...7.0.8) (2021-12-10)
|
package/dist/lib/field.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export class PageField {
|
|
|
10
10
|
* @throws {Error} When run on a complex field
|
|
11
11
|
*/
|
|
12
12
|
getValue(obj?: object): any;
|
|
13
|
-
putValue(obj
|
|
13
|
+
putValue(obj?: any, value?: undefined): PageField;
|
|
14
14
|
get name(): string;
|
|
15
15
|
get meta(): object;
|
|
16
16
|
/**
|
|
@@ -46,7 +46,7 @@ export class PageField {
|
|
|
46
46
|
* @param {ValidateContext} context Contextual information
|
|
47
47
|
* @returns {ValidationError[]} Errors, or an empty array if all valid
|
|
48
48
|
*/
|
|
49
|
-
runValidators(value: any, context
|
|
49
|
+
runValidators(value: any, context?: any): ValidationError[];
|
|
50
50
|
applyProcessors(value: any): any;
|
|
51
51
|
/**
|
|
52
52
|
* Apply all conditions to get the resulting boolean
|
package/dist/lib/field.js
CHANGED
|
@@ -107,7 +107,7 @@ class PageField {
|
|
|
107
107
|
}
|
|
108
108
|
throw new Error('Not yet supporting complex field types');
|
|
109
109
|
}
|
|
110
|
-
putValue(obj = Object.create(null), value) {
|
|
110
|
+
putValue(obj = Object.create(null), value = undefined) {
|
|
111
111
|
if (!__classPrivateFieldGet(this, _PageField_meta, "f").complex) {
|
|
112
112
|
/* eslint-disable-next-line no-param-reassign */
|
|
113
113
|
obj[__classPrivateFieldGet(this, _PageField_name, "f")] = value;
|
|
@@ -174,11 +174,18 @@ class PageField {
|
|
|
174
174
|
* @param {ValidateContext} context Contextual information
|
|
175
175
|
* @returns {ValidationError[]} Errors, or an empty array if all valid
|
|
176
176
|
*/
|
|
177
|
-
runValidators(value, context) {
|
|
177
|
+
runValidators(value, context = Object.create(null)) {
|
|
178
|
+
var _a;
|
|
178
179
|
// Skip validation if the field is empty and optional
|
|
179
180
|
if (__classPrivateFieldGet(this, _PageField_meta, "f").optional && (0, utils_js_1.isEmpty)(value)) {
|
|
180
181
|
return [];
|
|
181
182
|
}
|
|
183
|
+
// Skip validation if conditions are not met
|
|
184
|
+
// We duplicate value in context.fieldValue for historical reasons
|
|
185
|
+
context.fieldValue = (_a = context.fieldValue) !== null && _a !== void 0 ? _a : value;
|
|
186
|
+
if (!this.testConditions(context)) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
182
189
|
let errors = [];
|
|
183
190
|
for (let i = 0, l = __classPrivateFieldGet(this, _PageField_validators, "f").length; i < l; i++) {
|
|
184
191
|
// ESLint disabled as `i` is an integer
|
|
@@ -77,7 +77,7 @@ class PostalAddressObject extends ValidatorFactory_js_1.default {
|
|
|
77
77
|
const reAddrLine1 = /^\d+|[^\s]+[a-z0-9\-,.&#()/\\:;'" ]+$/i;
|
|
78
78
|
// UK Postcode regex taken from the dwp java pc checker
|
|
79
79
|
// https://github.com/dwp/postcode-format-validation
|
|
80
|
-
const rePostcode =
|
|
80
|
+
const rePostcode = /^(?![QVX])[A-Z]((?![IJZ])[A-Z][0-9](([0-9]?)|([ABEHMNPRVWXY]?))|([0-9]([0-9]?|[ABCDEFGHJKPSTUW]?))) ?[0-9]((?![CIKMOV])[A-Z]){2}$|^(BFPO)[ ]?[0-9]{1,4}$/i;
|
|
81
81
|
// [required, regex, strlenmax, error message]
|
|
82
82
|
const attributes = {
|
|
83
83
|
address1: [reqF.address1, reAddrLine1, cfg.strlenmax, cfg.errorMsgAddress1],
|
|
@@ -33,12 +33,10 @@ exports.default = ({ waypoint, fields = [], mountUrl, plan, }) => [
|
|
|
33
33
|
journeyContext: req.casa.journeyContext,
|
|
34
34
|
};
|
|
35
35
|
/* eslint-enable security/detect-object-injection */
|
|
36
|
-
|
|
37
|
-
errors
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
];
|
|
41
|
-
}
|
|
36
|
+
errors = [
|
|
37
|
+
...errors,
|
|
38
|
+
...field.runValidators(fieldValue, context),
|
|
39
|
+
];
|
|
42
40
|
}
|
|
43
41
|
// Validation passed with no errors
|
|
44
42
|
if (!errors.length) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dwp/govuk-casa",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "A framework for building GOVUK Collect-And-Submit-Applications",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git@github.com:dwp/govuk-casa.git"
|
|
8
|
+
},
|
|
5
9
|
"main": "dist/casa.js",
|
|
6
10
|
"module": "dist/mjs/casa.js",
|
|
7
11
|
"exports": {
|
|
@@ -45,44 +49,44 @@
|
|
|
45
49
|
"express-session": "1.17.2",
|
|
46
50
|
"govuk-frontend": "4.0.0",
|
|
47
51
|
"graphlib": "2.1.8",
|
|
48
|
-
"helmet": "
|
|
49
|
-
"i18next": "21.6.
|
|
50
|
-
"i18next-http-middleware": "3.1.
|
|
52
|
+
"helmet": "5.0.1",
|
|
53
|
+
"i18next": "21.6.6",
|
|
54
|
+
"i18next-http-middleware": "3.1.5",
|
|
51
55
|
"js-yaml": "4.1.0",
|
|
52
56
|
"lodash": "4.17.21",
|
|
53
|
-
"luxon": "2.
|
|
57
|
+
"luxon": "2.3.0",
|
|
54
58
|
"nunjucks": "3.2.3",
|
|
55
59
|
"uuid": "8.3.2",
|
|
56
60
|
"validator": "^13.7.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "7.16.
|
|
63
|
+
"@babel/core": "7.16.7",
|
|
60
64
|
"@babel/eslint-parser": "7.16.5",
|
|
61
|
-
"@babel/preset-env": "7.16.
|
|
62
|
-
"@commitlint/config-conventional": "
|
|
65
|
+
"@babel/preset-env": "7.16.8",
|
|
66
|
+
"@commitlint/config-conventional": "16.0.0",
|
|
63
67
|
"@dwp/casa-spiderplan": "2.0.0",
|
|
64
68
|
"@dwp/casa-spiderplan-a11y-plugin": "0.1.3",
|
|
65
69
|
"@dwp/casa-spiderplan-zap-plugin": "0.1.1",
|
|
66
|
-
"@dwp/eslint-config-base": "
|
|
70
|
+
"@dwp/eslint-config-base": "6.0.0",
|
|
67
71
|
"@types/express": "4.17.13",
|
|
68
|
-
"@types/node": "17.0.
|
|
69
|
-
"@types/nunjucks": "3.2.
|
|
72
|
+
"@types/node": "17.0.8",
|
|
73
|
+
"@types/nunjucks": "3.2.1",
|
|
70
74
|
"babel-eslint": "10.1.0",
|
|
71
|
-
"c8": "7.
|
|
75
|
+
"c8": "7.11.0",
|
|
72
76
|
"chai": "4.3.4",
|
|
73
|
-
"commitlint": "
|
|
74
|
-
"eslint": "
|
|
77
|
+
"commitlint": "16.0.2",
|
|
78
|
+
"eslint": "8.6.0",
|
|
75
79
|
"eslint-plugin-no-unsafe-regex": "1.0.0",
|
|
76
80
|
"eslint-plugin-security": "1.4.0",
|
|
77
81
|
"eslint-plugin-sonarjs": "0.11.0",
|
|
78
|
-
"fast-check": "2.
|
|
82
|
+
"fast-check": "2.21.0",
|
|
79
83
|
"husky": "7.0.4",
|
|
80
84
|
"mocha": "9.1.3",
|
|
81
|
-
"sass": "1.
|
|
85
|
+
"sass": "1.47.0",
|
|
82
86
|
"sinon": "12.0.1",
|
|
83
87
|
"sinon-chai": "3.7.0",
|
|
84
88
|
"standard-version": "9.3.2",
|
|
85
|
-
"supertest": "6.1
|
|
89
|
+
"supertest": "6.2.1",
|
|
86
90
|
"typescript": "4.5.4"
|
|
87
91
|
}
|
|
88
92
|
}
|