hmpo-form-wizard 14.0.0 → 15.0.0

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/eslint.config.js CHANGED
@@ -23,6 +23,9 @@ const styleRules = {
23
23
 
24
24
  module.exports = [
25
25
  js.configs.recommended,
26
+ {
27
+ ignores: ['example/public/**']
28
+ },
26
29
  {
27
30
  languageOptions: {
28
31
  ecmaVersion: 2022,
@@ -7,7 +7,7 @@
7
7
  "start": "node .",
8
8
  "postinstall": "npm run build",
9
9
  "build": "npm run build:sass && npm run build:js",
10
- "build:sass": "mkdir -p public/stylesheets; node-sass assets/stylesheets/app.scss --output-style compressed public/stylesheets/application.css",
10
+ "build:sass": "mkdir -p public/stylesheets; sass -q -I . -s compressed --no-source-map assets/stylesheets/app.scss public/stylesheets/application.css",
11
11
  "build:js": "mkdir -p public/javascripts; cat node_modules/govuk-frontend/govuk/all.js node_modules/hmpo-components/all.js assets/javascripts/*.js > public/javascripts/application.js"
12
12
  },
13
13
  "author": "HMPO",
@@ -23,7 +23,7 @@
23
23
  "hmpo-i18n": "latest",
24
24
  "hmpo-logger": "latest",
25
25
  "hmpo-model": "latest",
26
- "node-sass": "latest",
27
- "nunjucks": "latest"
26
+ "nunjucks": "latest",
27
+ "sass": "latest"
28
28
  }
29
29
  }
@@ -23,7 +23,7 @@ let validators = {
23
23
  },
24
24
 
25
25
  email(value) {
26
- return value === '' || validators.regex(value, /^[a-z0-9._%+-]+@([a-z0-9]+([a-z0-9-]*[a-z0-9]+)?\.)+[a-z]{2,6}$/i);
26
+ return value === '' || validators.regex(value, /^(?!.*\.\.)[a-z0-9_%+-](?:[a-z0-9._%+-]*[a-z0-9_%+-])?@([a-z0-9]+([a-z0-9-]*[a-z0-9]+)?\.)+[a-z]{2,6}$/i);
27
27
  },
28
28
 
29
29
  minlength(value, length) {
@@ -35,6 +35,12 @@ let validators = {
35
35
  return validators.string(value) && (value === '' || value.length <= length);
36
36
  },
37
37
 
38
+ maxwords(text, length) {
39
+ if (!validators.string(text)) return false;
40
+ const words = text.match(/\S+/g) || [];
41
+ return words.length <= length;
42
+ },
43
+
38
44
  exactlength(value, length) {
39
45
  return validators.string(value) && (value === '' || value.length === length);
40
46
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hmpo-form-wizard",
3
- "version": "14.0.0",
3
+ "version": "15.0.0",
4
4
  "description": "Routing and request handling for a multi-step form processes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -64,15 +64,46 @@ describe('validators', () => {
64
64
  null,
65
65
  'asdf.com',
66
66
  'asdf.',
67
+ '.asdf',
68
+ '.asdf.',
67
69
  'asdf@com.',
70
+ 'asdf@.com',
68
71
  'asdf@.com.',
72
+ '@com',
69
73
  '@.com',
70
74
  '@com.',
75
+ '@.com.',
76
+ '@example.com',
71
77
  'test.com@',
72
78
  'test@test@test.com',
79
+ 'test@@test.com',
80
+ '.test@example.com',
81
+ 'test.@example.com',
82
+ '.test.@example.com',
83
+ 'user..name@example.com',
73
84
  'test@.example.com',
85
+ 'test@example.com.',
86
+ 'test@.example.com.',
87
+ 'test@example..com',
88
+ 'test@exa mple.com',
89
+ 'te st@example.com',
90
+ 'test@x',
91
+ 'test@example.x',
92
+ 'test@somewhere',
93
+ 'test@example.somewhere',
74
94
  'test@example-.com',
75
- 'test@-.com'
95
+ 'test@-.com',
96
+ 'test@example,com',
97
+ 'test@example com',
98
+ '<test>@example.com',
99
+ 'user,name@example.com',
100
+ 'user`name@example.com',
101
+ 'user\'name@example.com',
102
+ ' test@example.com',
103
+ 'test @example.com',
104
+ 'test@example.com ',
105
+ 'test!#$%&\'*+/=?^_`{|}~@example.com',
106
+ 'test@example.com<'
76
107
  ];
77
108
  _.each(inputs, i => {
78
109
  it(testName(i), () => {
@@ -86,6 +117,9 @@ describe('validators', () => {
86
117
  '',
87
118
  't@i.co',
88
119
  'test@example.com',
120
+ '_@example.com',
121
+ '_%+-test@example.com',
122
+ 'test-+%_@example.com',
89
123
  'test+suffix@gmail.com',
90
124
  'test+suffix@digital.cabinet-office.gov.uk',
91
125
  'test.suffix@digital.cabinet-office.gov.uk',
@@ -163,6 +197,37 @@ describe('validators', () => {
163
197
 
164
198
  });
165
199
 
200
+ describe('maxwords', () => {
201
+
202
+ describe('invalid values', () => {
203
+ let inputs = [
204
+ [undefined, 1],
205
+ [100, 10],
206
+ ['asdfasdfasdf', 0],
207
+ ['asdf asdf asdf asdf asdf asdf asdf asdf', 3]
208
+ ];
209
+ _.each(inputs, i => {
210
+ it(testName(i), () => {
211
+ validators.maxwords.apply(null, i).should.not.be.ok;
212
+ });
213
+ });
214
+ });
215
+
216
+ describe('valid values', () => {
217
+ let inputs = [
218
+ ['', 0],
219
+ ['asdfasdf asdf asdf asdf asdf', 10],
220
+ ['123', 4]
221
+ ];
222
+ _.each(inputs, i => {
223
+ it(testName(i), () => {
224
+ validators.maxwords.apply(null, i).should.be.ok;
225
+ });
226
+ });
227
+ });
228
+
229
+ });
230
+
166
231
  describe('exactlength', () => {
167
232
 
168
233
  describe('invalid values', () => {