@planning-inspectorate/dynamic-forms 2.0.0 → 2.0.2

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/components/address/index.njk +1 -1
  3. package/src/components/boolean/index.njk +3 -3
  4. package/src/components/checkbox/index.njk +2 -2
  5. package/src/components/conditional/textarea.njk +1 -1
  6. package/src/components/conditional/unit.njk +1 -1
  7. package/src/components/date/index.njk +2 -2
  8. package/src/components/date-period/index.njk +3 -3
  9. package/src/components/date-time/index.njk +3 -3
  10. package/src/components/identifier/index.njk +1 -1
  11. package/src/components/multi-field-input/index.njk +2 -2
  12. package/src/components/number-entry/index.njk +6 -3
  13. package/src/components/radio/index.njk +7 -3
  14. package/src/components/select/index.njk +1 -1
  15. package/src/components/single-line-input/index.njk +3 -3
  16. package/src/components/text-entry/index.njk +3 -3
  17. package/src/components/text-entry-redact/index.njk +1 -1
  18. package/src/components/unit-option-entry/index.njk +4 -2
  19. package/src/validator/address-validator.js +1 -1
  20. package/src/validator/address-validator.test.js +1 -1
  21. package/src/validator/coordinates-validator.js +6 -6
  22. package/src/validator/coordinates-validator.test.js +10 -14
  23. package/src/validator/date-validator.js +2 -2
  24. package/src/validator/date-validator.test.js +6 -6
  25. package/test/snapshots/add-insurance.html +19 -23
  26. package/test/snapshots/companions.html +2 -9
  27. package/test/snapshots/departure-date.html +1 -5
  28. package/test/snapshots/holiday-activities.html +25 -29
  29. package/test/snapshots/holiday-arrival.html +2 -3
  30. package/test/snapshots/holiday-description.html +1 -5
  31. package/test/snapshots/holiday-destination.html +0 -4
  32. package/test/snapshots/holiday-period.html +2 -9
  33. package/test/snapshots/holiday-snack.html +1 -5
  34. package/test/snapshots/hotel-address.html +0 -1
  35. package/test/snapshots/luggage-weight-units.html +2 -11
  36. package/test/snapshots/nights.html +1 -6
  37. package/test/snapshots/secret-wish.html +0 -1
  38. package/test/snapshots/travel-class.html +1 -4
  39. package/test/snapshots/travel-insurance-type.html +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/dynamic-forms",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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",
@@ -14,7 +14,7 @@
14
14
  <div class="govuk-grid-row">
15
15
  <div class="govuk-grid-column-two-thirds">
16
16
  <form action="" method="post" novalidate>
17
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
17
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
18
18
  {% call govukFieldset({
19
19
  legend: {
20
20
  text: question.question,
@@ -14,7 +14,7 @@
14
14
  <div class="govuk-grid-row">
15
15
  <div class="govuk-grid-column-two-thirds">
16
16
  <form action="" method="post" novalidate>
17
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
17
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
18
18
  {% if question.interfaceType === 'radio' %}
19
19
  {{ govukRadios({
20
20
  classes: "govuk-radios",
@@ -30,7 +30,7 @@
30
30
  classes: "govuk-fieldset__legend--l"
31
31
  }
32
32
  },
33
- hint: { text: question.hint },
33
+ hint: question.hint and { text: question.hint },
34
34
  items: question.options
35
35
  }) }}
36
36
 
@@ -42,7 +42,7 @@
42
42
  errorMessage: errors[question.fieldName] and {
43
43
  text: errors[question.fieldName].msg
44
44
  },
45
- hint: {
45
+ hint: htmlHint and {
46
46
  html: htmlHint
47
47
  },
48
48
  fieldset: {
@@ -7,7 +7,7 @@
7
7
  <div class="govuk-grid-row">
8
8
  <div class="govuk-grid-column-two-thirds">
9
9
  <form action="" method="post" novalidate>
10
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
10
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
11
11
  {{ govukCheckboxes({
12
12
  classes: "govuk-checkboxes",
13
13
  idPrefix: question.fieldName,
@@ -15,7 +15,7 @@
15
15
  errorMessage: errors[question.fieldName] and {
16
16
  text: errors[question.fieldName].msg
17
17
  },
18
- hint: {
18
+ hint: question.description and {
19
19
  text: question.description
20
20
  },
21
21
  fieldset: {
@@ -4,7 +4,7 @@
4
4
  label: {
5
5
  text: question
6
6
  },
7
- hint: {
7
+ hint: hint and {
8
8
  text: hint
9
9
  },
10
10
  id: fieldName,
@@ -1,7 +1,7 @@
1
1
  {% from "govuk/components/input/macro.njk" import govukInput %}
2
2
 
3
3
  {{ govukInput({
4
- hint: {
4
+ hint: hint and {
5
5
  text: hint
6
6
  },
7
7
  label: {
@@ -17,7 +17,7 @@
17
17
  <div class="govuk-grid-row">
18
18
  <div class="govuk-grid-column-two-thirds">
19
19
  <form action="" method="post" novalidate>
20
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
20
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
21
21
  {{ govukDateInput({
22
22
  id: question.fieldName,
23
23
  fieldset: {
@@ -27,7 +27,7 @@
27
27
  classes: "govuk-fieldset__legend--l"
28
28
  }
29
29
  },
30
- hint: {
30
+ hint: question.hint and {
31
31
  text: question.hint
32
32
  },
33
33
  errorMessage: errorSummary and {
@@ -23,7 +23,7 @@
23
23
  <div class="govuk-grid-row">
24
24
  <div class="govuk-grid-column-two-thirds">
25
25
  <form action="" method="post" novalidate>
26
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
26
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
27
27
 
28
28
  {{ govukFieldset({
29
29
  legend: {
@@ -40,7 +40,7 @@
40
40
  text: labels.start
41
41
  }
42
42
  },
43
- hint: {
43
+ hint: question.hint and {
44
44
  text: question.hint
45
45
  },
46
46
  errorMessage: errorSummary and {
@@ -78,7 +78,7 @@
78
78
  text: labels.end
79
79
  }
80
80
  },
81
- hint: {
81
+ hint: question.hint and {
82
82
  text: question.hint
83
83
  },
84
84
  errorMessage: errorSummary and {
@@ -29,7 +29,7 @@
29
29
  <div class="govuk-grid-row">
30
30
  <div class="govuk-grid-column-two-thirds">
31
31
  <form action="" method="post" novalidate>
32
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
32
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
33
33
  {{ govukDateInput({
34
34
  id: question.fieldName,
35
35
  fieldset: {
@@ -69,13 +69,13 @@
69
69
 
70
70
  <div class="govuk-form-group{% if errors[hour].msg or errors[minutes].msg or errors[period].msg %} govuk-form-group--error{% endif %}">
71
71
  <fieldset class="govuk-fieldset" role="group">
72
- <div id="{{ question.fieldName }}-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
72
+ <div id="{{ question.fieldName }}-time-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
73
73
  {% if errors[hour].msg or errors[minutes].msg or errors[period].msg %}
74
74
  <p id="{{ question.fieldName }}-error" class="govuk-error-message">
75
75
  <span class="govuk-visually-hidden">Error:</span> {{ errors[hour].msg or errors[minutes].msg or errors[period].msg }}
76
76
  </p>
77
77
  {% endif %}
78
- <div class="govuk-date-input" id={{ question.fieldName }}>
78
+ <div class="govuk-date-input" id="{{ question.fieldName }}-time">
79
79
  <div class="govuk-date-input__item">
80
80
  {{ govukInput({
81
81
  classes: "govuk-input--width-2 govuk-input--error" if errors[question.fieldName] or errors[hour] else "govuk-input--width-2",
@@ -8,7 +8,7 @@
8
8
  <div class="govuk-grid-row">
9
9
  <div class="govuk-grid-column-two-thirds">
10
10
  <form action="" method="post" novalidate>
11
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
12
12
  {% if question.label %}
13
13
  <h1 class="govuk-heading-l">
14
14
  {{ question.question }}
@@ -11,7 +11,7 @@
11
11
  <div class="govuk-grid-row">
12
12
  <div class="govuk-grid-column-two-thirds">
13
13
  <form action="" method="post" novalidate>
14
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
14
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
15
15
 
16
16
  {% call govukFieldset({
17
17
  legend: {
@@ -53,7 +53,7 @@
53
53
  prefix: inputField.prefix,
54
54
  suffix: inputField.suffix,
55
55
  value: inputField.value,
56
- hint: {
56
+ hint: inputField.hint and {
57
57
  text: inputField.hint
58
58
  },
59
59
  classes: inputField.classes or "govuk-input-!-width-three-quarters",
@@ -7,11 +7,14 @@
7
7
  <div class="govuk-grid-row">
8
8
  <div class="govuk-grid-column-two-thirds">
9
9
  <h1 class="govuk-heading-l">{{ question.question }}</h1>
10
- <p class="govuk-body">{{ question.description }}</p>
10
+ {%- if question.description %}
11
+ <p class="govuk-body">{{ question.description }}</p>
12
+ {%- endif %}
13
+
11
14
  <form action="" method="post" novalidate>
12
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
15
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
13
16
  {{ govukInput({
14
- hint: {
17
+ hint: question.hint and {
15
18
  text: question.hint
16
19
  },
17
20
  label: {
@@ -8,11 +8,13 @@
8
8
  <div class="govuk-grid-row">
9
9
  <div class="govuk-grid-column-two-thirds">
10
10
  <form action="" method="post" novalidate>
11
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
12
12
 
13
13
  {% if question.legend %}
14
14
  <h1 class="govuk-heading-l">{{ question.question }}</h1>
15
- <p class="govuk-body">{{ question.description }}</p>
15
+ {%- if question.description %}
16
+ <p class="govuk-body">{{ question.description }}</p>
17
+ {%- endif -%}
16
18
 
17
19
  {% if question.html %}
18
20
  {% include question.html ignore missing %}
@@ -45,7 +47,9 @@
45
47
  }
46
48
  }) %}
47
49
 
48
- <p class="govuk-body">{{ question.description }}</p>
50
+ {%- if question.description %}
51
+ <p class="govuk-body">{{ question.description }}</p>
52
+ {%- endif -%}
49
53
 
50
54
  {% if question.html %}
51
55
  {% include question.html ignore missing %}
@@ -27,7 +27,7 @@
27
27
  classes: "govuk-label--l",
28
28
  isPageHeading: true
29
29
  },
30
- hint: {
30
+ hint: question.hint and {
31
31
  text: question.hint
32
32
  },
33
33
  errorMessage: errors[question.fieldName] and {
@@ -8,7 +8,7 @@
8
8
  <div class="govuk-grid-row">
9
9
  <div class="govuk-grid-column-two-thirds">
10
10
  <form action="" method="post" novalidate>
11
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
12
12
  {% if question.label %}
13
13
  <h1 class="govuk-heading-l">
14
14
  {{ question.question }}
@@ -34,7 +34,7 @@
34
34
  id: question.fieldName,
35
35
  name: question.fieldName,
36
36
  value: question.value,
37
- hint: { text: question.hint },
37
+ hint: question.hint and { text: question.hint },
38
38
  errorMessage: errors[question.fieldName] and {
39
39
  text: errors[question.fieldName].msg
40
40
  },
@@ -58,7 +58,7 @@
58
58
  id: question.fieldName,
59
59
  name: question.fieldName,
60
60
  value: question.value,
61
- hint: { text: question.hint },
61
+ hint: question.hint and { text: question.hint },
62
62
  errorMessage: errors[question.fieldName] and {
63
63
  text: errors[question.fieldName].msg
64
64
  },
@@ -9,7 +9,7 @@
9
9
  <div class="govuk-grid-row">
10
10
  <div class="govuk-grid-column-two-thirds">
11
11
  <form action="" method="post" novalidate>
12
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
12
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
13
13
  {% if question.label %}
14
14
  <h1 class="govuk-heading-l">
15
15
  {{ question.question }}
@@ -26,7 +26,7 @@
26
26
  id: question.fieldName,
27
27
  name: question.fieldName,
28
28
  value: question.value,
29
- hint: { text: question.hint },
29
+ hint: question.hint and { text: question.hint },
30
30
  errorMessage: errors[question.fieldName] and {
31
31
  text: errors[question.fieldName].msg
32
32
  },
@@ -48,7 +48,7 @@
48
48
  id: question.fieldName,
49
49
  name: question.fieldName,
50
50
  value: question.value,
51
- hint: { text: question.hint },
51
+ hint: question.hint and { text: question.hint },
52
52
  errorMessage: errors[question.fieldName] and {
53
53
  text: errors[question.fieldName].msg
54
54
  },
@@ -11,7 +11,7 @@
11
11
  <div class="govuk-grid-row">
12
12
  <div class="govuk-grid-column-two-thirds">
13
13
  <form action="" method="post" novalidate>
14
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
14
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
15
15
 
16
16
  {% if question.label %}
17
17
  {{ govukLabel({
@@ -8,7 +8,7 @@
8
8
  <div class="govuk-grid-row">
9
9
  <div class="govuk-grid-column-two-thirds">
10
10
  <form action="" method="post" novalidate>
11
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
12
12
 
13
13
  {% call govukFieldset({
14
14
  legend: {
@@ -18,7 +18,9 @@
18
18
  }
19
19
  }) %}
20
20
 
21
- <p class="govuk-body">{{ question.description }}</p>
21
+ {%- if question.description %}
22
+ <p class="govuk-body">{{ question.description }}</p>
23
+ {%- endif -%}
22
24
  {% if question.html %}
23
25
  {% include question.html ignore missing %}
24
26
  {% endif %}
@@ -66,7 +66,7 @@ export default class AddressValidator extends BaseValidator {
66
66
  if (!this.requiredFields?.addressLine1) {
67
67
  validator.optional({ checkFalsy: true });
68
68
  } else {
69
- validator.notEmpty().withMessage(`Enter an address line 1`);
69
+ validator.notEmpty().withMessage(`Enter address line 1, typically the building and street`);
70
70
  }
71
71
 
72
72
  return validator
@@ -74,7 +74,7 @@ describe('AddressValidator', () => {
74
74
  const errors = await _validationMappedErrors(req, question);
75
75
 
76
76
  assert.strictEqual(Object.keys(errors).length, 5);
77
- assert.strictEqual(errors.testField_addressLine1.msg, 'Enter an address line 1');
77
+ assert.strictEqual(errors.testField_addressLine1.msg, 'Enter address line 1, typically the building and street');
78
78
  assert.strictEqual(errors.testField_addressLine2.msg, 'Enter an address line 2');
79
79
  assert.strictEqual(errors.testField_townCity.msg, 'Enter a town or city');
80
80
  assert.strictEqual(errors.testField_county.msg, 'Enter a county');
@@ -24,22 +24,22 @@ export default class CoordinatesValidator extends BaseValidator {
24
24
  body(this.northing.fieldName)
25
25
  .optional({ checkFalsy: true })
26
26
  .isNumeric()
27
- .withMessage(`Please a numeric value for the Grid reference ${this.northing.title}`)
27
+ .withMessage(`The ${this.northing.title} grid reference must be a number`)
28
28
  .isLength({ min: requiredCoordinateLength, max: requiredCoordinateLength })
29
- .withMessage(`Enter ${requiredCoordinateLength} digits for the Grid reference ${this.northing.title}`),
29
+ .withMessage(`The ${this.northing.title} grid reference must contain ${requiredCoordinateLength} digits`),
30
30
 
31
31
  body(this.easting.fieldName)
32
32
  .optional({ checkFalsy: true })
33
33
  .isNumeric()
34
- .withMessage(`Please a numeric value for the Grid reference ${this.easting.title}`)
34
+ .withMessage(`The ${this.easting.title} grid reference must be a number`)
35
35
  .isLength({ min: requiredCoordinateLength, max: requiredCoordinateLength })
36
- .withMessage(`Enter ${requiredCoordinateLength} digits for the Grid reference ${this.easting.title}`),
36
+ .withMessage(`The ${this.easting.title} grid reference must contain ${requiredCoordinateLength} digits`),
37
37
 
38
38
  // validate northing has been populated if value for easting provided
39
39
  body(this.northing.fieldName).custom((_, { req }) => {
40
40
  const { siteNorthing, siteEasting } = req.body;
41
41
  if (!siteNorthing && siteEasting) {
42
- throw new Error(`Enter 6 digits for the Grid reference ${this.northing.title}`);
42
+ throw new Error(`The ${this.northing.title} grid reference must contain 6 digits`);
43
43
  }
44
44
  return true;
45
45
  }),
@@ -48,7 +48,7 @@ export default class CoordinatesValidator extends BaseValidator {
48
48
  body(this.easting.fieldName).custom((_, { req }) => {
49
49
  const { siteNorthing, siteEasting } = req.body;
50
50
  if (siteNorthing && !siteEasting) {
51
- throw new Error(`Enter 6 digits for the Grid reference ${this.easting.title}`);
51
+ throw new Error(`The ${this.easting.title} grid reference must contain 6 digits`);
52
52
  }
53
53
  return true;
54
54
  })
@@ -30,13 +30,9 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
30
30
  const coordinatesValidator = new CoordinatesValidator(northing, easting);
31
31
  const errors = await _validationMappedErrors(req, coordinatesValidator);
32
32
  assert.strictEqual(Object.keys(errors).length, 2);
33
- assert.strictEqual(
34
- errors[northing.fieldName].msg,
35
- `Please a numeric value for the Grid reference ${northing.title}`
36
- );
37
- assert.strictEqual(errors[easting.fieldName].msg, `Please a numeric value for the Grid reference ${easting.title}`);
33
+ assert.strictEqual(errors[northing.fieldName].msg, `The ${northing.title} grid reference must be a number`);
34
+ assert.strictEqual(errors[easting.fieldName].msg, `The ${easting.title} grid reference must be a number`);
38
35
  });
39
-
40
36
  it('should return an error message if coordinates are not the required length', async () => {
41
37
  const req = {
42
38
  body: {
@@ -49,8 +45,8 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
49
45
  const errors = await _validationMappedErrors(req, coordinatesValidator);
50
46
 
51
47
  assert.strictEqual(Object.keys(errors).length, 2);
52
- assert.strictEqual(errors[northing.fieldName].msg, `Enter 6 digits for the Grid reference ${northing.title}`);
53
- assert.strictEqual(errors[easting.fieldName].msg, `Enter 6 digits for the Grid reference ${easting.title}`);
48
+ assert.strictEqual(errors[northing.fieldName].msg, `The ${northing.title} grid reference must contain 6 digits`);
49
+ assert.strictEqual(errors[easting.fieldName].msg, `The ${easting.title} grid reference must contain 6 digits`);
54
50
  });
55
51
 
56
52
  it('should return an error message if northing is populated but easting is not', async () => {
@@ -65,7 +61,7 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
65
61
  const errors = await _validationMappedErrors(req, coordinatesValidator);
66
62
 
67
63
  assert.strictEqual(Object.keys(errors).length, 1);
68
- assert.strictEqual(errors[easting.fieldName].msg, `Enter 6 digits for the Grid reference ${easting.title}`);
64
+ assert.strictEqual(errors[easting.fieldName].msg, `The ${easting.title} grid reference must contain 6 digits`);
69
65
  });
70
66
 
71
67
  it('should return an error message if easting is populated but northing is not', async () => {
@@ -80,7 +76,7 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
80
76
  const errors = await _validationMappedErrors(req, coordinatesValidator);
81
77
 
82
78
  assert.strictEqual(Object.keys(errors).length, 1);
83
- assert.strictEqual(errors[northing.fieldName].msg, `Enter 6 digits for the Grid reference ${northing.title}`);
79
+ assert.strictEqual(errors[northing.fieldName].msg, `The ${northing.title} grid reference must contain 6 digits`);
84
80
  });
85
81
 
86
82
  it('should return an error message if northing is populated but not required length and easting is not populated', async () => {
@@ -95,8 +91,8 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
95
91
  const errors = await _validationMappedErrors(req, coordinatesValidator);
96
92
 
97
93
  assert.strictEqual(Object.keys(errors).length, 2);
98
- assert.strictEqual(errors[northing.fieldName].msg, `Enter 6 digits for the Grid reference ${northing.title}`);
99
- assert.strictEqual(errors[easting.fieldName].msg, `Enter 6 digits for the Grid reference ${easting.title}`);
94
+ assert.strictEqual(errors[northing.fieldName].msg, `The ${northing.title} grid reference must contain 6 digits`);
95
+ assert.strictEqual(errors[easting.fieldName].msg, `The ${easting.title} grid reference must contain 6 digits`);
100
96
  });
101
97
 
102
98
  it('should return an error message if easting is populated but not required length and northing is not populated', async () => {
@@ -111,8 +107,8 @@ describe('./src/dynamic-forms/validator/coordinates-validator.js', () => {
111
107
  const errors = await _validationMappedErrors(req, coordinatesValidator);
112
108
 
113
109
  assert.strictEqual(Object.keys(errors).length, 2);
114
- assert.strictEqual(errors[northing.fieldName].msg, `Enter 6 digits for the Grid reference ${northing.title}`);
115
- assert.strictEqual(errors[easting.fieldName].msg, `Enter 6 digits for the Grid reference ${easting.title}`);
110
+ assert.strictEqual(errors[northing.fieldName].msg, `The ${northing.title} grid reference must contain 6 digits`);
111
+ assert.strictEqual(errors[easting.fieldName].msg, `The ${easting.title} grid reference must contain 6 digits`);
116
112
  });
117
113
  });
118
114
 
@@ -184,8 +184,8 @@ export default class DateValidator extends BaseValidator {
184
184
  noDayMonthErrorMessage: `${capitalisedInputLabel} must include a day and month`,
185
185
  noDayYearErrorMessage: `${capitalisedInputLabel} must include a day and year`,
186
186
  noMonthYearErrorMessage: `${capitalisedInputLabel} must include a month and year`,
187
- invalidDateErrorMessage: `${capitalisedInputLabel} must be a real date`,
188
- invalidMonthErrorMessage: `${capitalisedInputLabel} month must be a real month`,
187
+ invalidDateErrorMessage: `${capitalisedInputLabel} day must be a real day`,
188
+ invalidMonthErrorMessage: `${capitalisedInputLabel} month must be between 1 and 12`,
189
189
  invalidYearErrorMessage: `${capitalisedInputLabel} year must include 4 numbers`,
190
190
  futureDateErrorMessage: `${capitalisedInputLabel} must be today or in the past`,
191
191
  pastDateErrorMessage: `${capitalisedInputLabel} must be today or in the future`
@@ -196,7 +196,7 @@ describe('./src/dynamic-forms/validator/date-validator.js', () => {
196
196
  const errors = await _validationMappedErrors(req, question, 'the required date');
197
197
 
198
198
  assert.strictEqual(Object.keys(errors).length, 1);
199
- assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date must be a real date');
199
+ assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date day must be a real day');
200
200
  });
201
201
 
202
202
  it('throws error if invalid month provided', async () => {
@@ -215,7 +215,7 @@ describe('./src/dynamic-forms/validator/date-validator.js', () => {
215
215
  const errors = await _validationMappedErrors(req, question, 'the required date');
216
216
 
217
217
  assert.strictEqual(Object.keys(errors).length, 1);
218
- assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be a real month');
218
+ assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be between 1 and 12');
219
219
  });
220
220
 
221
221
  it('throws error if invalid year provided', async () => {
@@ -336,8 +336,8 @@ describe('./src/dynamic-forms/validator/date-validator.js', () => {
336
336
  const errors = await _validationMappedErrors(req, question, 'the required date');
337
337
 
338
338
  assert.strictEqual(Object.keys(errors).length, 3);
339
- assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date must be a real date');
340
- assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be a real month');
339
+ assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date day must be a real day');
340
+ assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be between 1 and 12');
341
341
  assert.strictEqual(errors[`${question.fieldName}_year`].msg, 'The required date year must include 4 numbers');
342
342
  });
343
343
 
@@ -357,8 +357,8 @@ describe('./src/dynamic-forms/validator/date-validator.js', () => {
357
357
  const errors = await _validationMappedErrors(req, question, 'the required date');
358
358
 
359
359
  assert.strictEqual(Object.keys(errors).length, 3);
360
- assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date must be a real date');
361
- assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be a real month');
360
+ assert.strictEqual(errors[`${question.fieldName}_day`].msg, 'The required date day must be a real day');
361
+ assert.strictEqual(errors[`${question.fieldName}_month`].msg, 'The required date month must be between 1 and 12');
362
362
  assert.strictEqual(errors[`${question.fieldName}_year`].msg, 'The required date year must include 4 numbers');
363
363
  });
364
364
 
@@ -1,32 +1,28 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <div class="govuk-form-group">
6
- <fieldset class="govuk-fieldset" aria-describedby="addInsurance-hint">
7
- <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
8
- <h1 class="govuk-fieldset__heading">
9
- Do you want to add travel insurance to your holiday?
10
- </h1>
11
- </legend>
12
- <div id="addInsurance-hint" class="govuk-hint">
13
-
5
+ <fieldset class="govuk-fieldset">
6
+ <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
7
+ <h1 class="govuk-fieldset__heading">
8
+ Do you want to add travel insurance to your holiday?
9
+ </h1>
10
+ </legend>
11
+ <div class="govuk-radios govuk-radios" data-module="govuk-radios">
12
+ <div class="govuk-radios__item">
13
+ <input class="govuk-radios__input" id="addInsurance" name="addInsurance" type="radio" value="yes" data-cy="answer-yes">
14
+ <label class="govuk-label govuk-radios__label" for="addInsurance">
15
+ Yes
16
+ </label>
14
17
  </div>
15
- <div class="govuk-radios govuk-radios" data-module="govuk-radios">
16
- <div class="govuk-radios__item">
17
- <input class="govuk-radios__input" id="addInsurance" name="addInsurance" type="radio" value="yes" data-cy="answer-yes">
18
- <label class="govuk-label govuk-radios__label" for="addInsurance">
19
- Yes
20
- </label>
21
- </div>
22
- <div class="govuk-radios__item">
23
- <input class="govuk-radios__input" id="addInsurance-2" name="addInsurance" type="radio" value="no" data-cy="answer-no">
24
- <label class="govuk-label govuk-radios__label" for="addInsurance-2">
25
- No
26
- </label>
27
- </div>
18
+ <div class="govuk-radios__item">
19
+ <input class="govuk-radios__input" id="addInsurance-2" name="addInsurance" type="radio" value="no" data-cy="answer-no">
20
+ <label class="govuk-label govuk-radios__label" for="addInsurance-2">
21
+ No
22
+ </label>
28
23
  </div>
29
- </fieldset>
24
+ </div>
25
+ </fieldset>
30
26
  </div>
31
27
 
32
28
 
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
  <fieldset class="govuk-fieldset">
7
6
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
@@ -16,20 +15,14 @@
16
15
  <label class="govuk-label govuk-label" for="name">
17
16
  Name
18
17
  </label>
19
- <div id="name-hint" class="govuk-hint">
20
-
21
- </div>
22
- <input class="govuk-input govuk-input-!-width-three-quarters" id="name" name="name" type="text" aria-describedby="name-hint">
18
+ <input class="govuk-input govuk-input-!-width-three-quarters" id="name" name="name" type="text">
23
19
  </div>
24
20
 
25
21
  <div class="govuk-form-group">
26
22
  <label class="govuk-label govuk-label" for="age">
27
23
  Age
28
24
  </label>
29
- <div id="age-hint" class="govuk-hint">
30
-
31
- </div>
32
- <input class="govuk-input govuk-input-!-width-three-quarters" id="age" name="age" type="text" aria-describedby="age-hint">
25
+ <input class="govuk-input govuk-input-!-width-three-quarters" id="age" name="age" type="text">
33
26
  </div>
34
27
 
35
28
 
@@ -1,17 +1,13 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <div class="govuk-form-group">
6
- <fieldset class="govuk-fieldset" role="group" aria-describedby="departureDate-hint">
5
+ <fieldset class="govuk-fieldset" role="group">
7
6
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
8
7
  <h1 class="govuk-fieldset__heading">
9
8
  When do you want to start your holiday?
10
9
  </h1>
11
10
  </legend>
12
- <div id="departureDate-hint" class="govuk-hint">
13
-
14
- </div>
15
11
  <div class="govuk-date-input" id="departureDate">
16
12
  <div class="govuk-date-input__item">
17
13
  <div class="govuk-form-group">
@@ -1,38 +1,34 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <div class="govuk-form-group">
6
- <fieldset class="govuk-fieldset" aria-describedby="holidayActivities-hint">
7
- <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
8
- <h1 class="govuk-fieldset__heading">
9
- Which activities do you want to do on holiday?
10
- </h1>
11
- </legend>
12
- <div id="holidayActivities-hint" class="govuk-hint">
13
-
5
+ <fieldset class="govuk-fieldset">
6
+ <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
7
+ <h1 class="govuk-fieldset__heading">
8
+ Which activities do you want to do on holiday?
9
+ </h1>
10
+ </legend>
11
+ <div class="govuk-checkboxes govuk-checkboxes" data-module="govuk-checkboxes">
12
+ <div class="govuk-checkboxes__item">
13
+ <input class="govuk-checkboxes__input" id="holidayActivities" name="holidayActivities" type="checkbox" value="swimming" data-cy="answer-swimming">
14
+ <label class="govuk-label govuk-checkboxes__label" for="holidayActivities">
15
+ Swimming
16
+ </label>
14
17
  </div>
15
- <div class="govuk-checkboxes govuk-checkboxes" data-module="govuk-checkboxes">
16
- <div class="govuk-checkboxes__item">
17
- <input class="govuk-checkboxes__input" id="holidayActivities" name="holidayActivities" type="checkbox" value="swimming" data-cy="answer-swimming">
18
- <label class="govuk-label govuk-checkboxes__label" for="holidayActivities">
19
- Swimming
20
- </label>
21
- </div>
22
- <div class="govuk-checkboxes__item">
23
- <input class="govuk-checkboxes__input" id="holidayActivities-2" name="holidayActivities" type="checkbox" value="hiking" data-cy="answer-hiking">
24
- <label class="govuk-label govuk-checkboxes__label" for="holidayActivities-2">
25
- Hiking
26
- </label>
27
- </div>
28
- <div class="govuk-checkboxes__item">
29
- <input class="govuk-checkboxes__input" id="holidayActivities-3" name="holidayActivities" type="checkbox" value="sightseeing" data-cy="answer-sightseeing">
30
- <label class="govuk-label govuk-checkboxes__label" for="holidayActivities-3">
31
- Sightseeing
32
- </label>
33
- </div>
18
+ <div class="govuk-checkboxes__item">
19
+ <input class="govuk-checkboxes__input" id="holidayActivities-2" name="holidayActivities" type="checkbox" value="hiking" data-cy="answer-hiking">
20
+ <label class="govuk-label govuk-checkboxes__label" for="holidayActivities-2">
21
+ Hiking
22
+ </label>
34
23
  </div>
35
- </fieldset>
24
+ <div class="govuk-checkboxes__item">
25
+ <input class="govuk-checkboxes__input" id="holidayActivities-3" name="holidayActivities" type="checkbox" value="sightseeing" data-cy="answer-sightseeing">
26
+ <label class="govuk-label govuk-checkboxes__label" for="holidayActivities-3">
27
+ Sightseeing
28
+ </label>
29
+ </div>
30
+ </div>
31
+ </fieldset>
36
32
  </div>
37
33
 
38
34
  <button type="submit" class="govuk-button" data-module="govuk-button" data-cy="button-save-and-continue">
@@ -8,7 +8,6 @@
8
8
  <div class="govuk-grid-row">
9
9
  <div class="govuk-grid-column-two-thirds">
10
10
  <form action="" method="post" novalidate>
11
- <input type="hidden" name="_csrf" value="">
12
11
  <div class="govuk-form-group">
13
12
  <fieldset class="govuk-fieldset" role="group">
14
13
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
@@ -48,8 +47,8 @@
48
47
 
49
48
  <div class="govuk-form-group">
50
49
  <fieldset class="govuk-fieldset" role="group">
51
- <div id="holidayArrival-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
52
- <div class="govuk-date-input" id=holidayArrival>
50
+ <div id="holidayArrival-time-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
51
+ <div class="govuk-date-input" id="holidayArrival-time">
53
52
  <div class="govuk-date-input__item">
54
53
  <div class="govuk-form-group">
55
54
  <label class="govuk-label" for="holidayArrival_hour">
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <h1 class="govuk-heading-l">
6
5
  Describe your ideal holiday.
7
6
  </h1>
@@ -11,10 +10,7 @@
11
10
  <label class="govuk-label" for="holidayDescription">
12
11
  Description
13
12
  </label>
14
- <div id="holidayDescription-hint" class="govuk-hint">
15
-
16
- </div>
17
- <textarea class="govuk-textarea" id="holidayDescription" name="holidayDescription" rows="5" aria-describedby="holidayDescription-hint"></textarea>
13
+ <textarea class="govuk-textarea" id="holidayDescription" name="holidayDescription" rows="5"></textarea>
18
14
  </div>
19
15
 
20
16
 
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
 
7
6
  <fieldset class="govuk-fieldset">
@@ -11,9 +10,6 @@
11
10
  </h1>
12
11
  </legend>
13
12
 
14
- <p class="govuk-body"></p>
15
-
16
-
17
13
  <div class="govuk-form-group">
18
14
  <div class="govuk-radios govuk-radios" data-module="govuk-radios">
19
15
  <div class="govuk-radios__item">
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
  <fieldset class="govuk-fieldset">
7
6
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
@@ -13,13 +12,10 @@
13
12
 
14
13
 
15
14
  <div class="govuk-form-group">
16
- <fieldset class="govuk-fieldset" role="group" aria-describedby="holidayPeriod_start-hint">
15
+ <fieldset class="govuk-fieldset" role="group">
17
16
  <legend class="govuk-fieldset__legend">
18
17
  Start
19
18
  </legend>
20
- <div id="holidayPeriod_start-hint" class="govuk-hint">
21
-
22
- </div>
23
19
  <div class="govuk-date-input" id="holidayPeriod_start">
24
20
  <div class="govuk-date-input__item">
25
21
  <div class="govuk-form-group">
@@ -51,13 +47,10 @@
51
47
 
52
48
 
53
49
  <div class="govuk-form-group">
54
- <fieldset class="govuk-fieldset" role="group" aria-describedby="holidayPeriod_end-hint">
50
+ <fieldset class="govuk-fieldset" role="group">
55
51
  <legend class="govuk-fieldset__legend">
56
52
  End
57
53
  </legend>
58
- <div id="holidayPeriod_end-hint" class="govuk-hint">
59
-
60
- </div>
61
54
  <div class="govuk-date-input" id="holidayPeriod_end">
62
55
  <div class="govuk-date-input__item">
63
56
  <div class="govuk-form-group">
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <h1 class="govuk-heading-l">
6
5
  What is your favourite snack to eat on holiday?
7
6
  </h1>
@@ -12,10 +11,7 @@
12
11
  <label class="govuk-label govuk-label" for="holidaySnack">
13
12
  Snack
14
13
  </label>
15
- <div id="holidaySnack-hint" class="govuk-hint">
16
-
17
- </div>
18
- <input class="govuk-input" id="holidaySnack" name="holidaySnack" type="text" value="" aria-describedby="holidaySnack-hint">
14
+ <input class="govuk-input" id="holidaySnack" name="holidaySnack" type="text" value="">
19
15
  </div>
20
16
 
21
17
 
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
  <fieldset class="govuk-fieldset">
6
5
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
7
6
  <h1 class="govuk-fieldset__heading">
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
  <fieldset class="govuk-fieldset">
7
6
  <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
@@ -10,8 +9,6 @@
10
9
  </h1>
11
10
  </legend>
12
11
 
13
- <p class="govuk-body"></p>
14
-
15
12
  <div class="govuk-form-group">
16
13
  <div class="govuk-radios govuk-radios" data-module="govuk-radios">
17
14
  <div class="govuk-radios__item">
@@ -25,11 +22,8 @@
25
22
  <label class="govuk-label" for="luggageWeightValue_kg">
26
23
  Weight in kilograms
27
24
  </label>
28
- <div id="luggageWeightValue_kg-hint" class="govuk-hint">
29
-
30
- </div>
31
25
  <div class="govuk-input__wrapper">
32
- <input class="govuk-input govuk-input--width-5" id="luggageWeightValue_kg" name="luggageWeightValue_kg" type="text" spellcheck="false" value="" aria-describedby="luggageWeightValue_kg-hint" inputmode="numeric">
26
+ <input class="govuk-input govuk-input--width-5" id="luggageWeightValue_kg" name="luggageWeightValue_kg" type="text" spellcheck="false" value="" inputmode="numeric">
33
27
  <div class="govuk-input__suffix" aria-hidden="true">kg</div>
34
28
  </div>
35
29
  </div>
@@ -45,11 +39,8 @@
45
39
  <label class="govuk-label" for="luggageWeightValue_lbs">
46
40
  Weight in pounds
47
41
  </label>
48
- <div id="luggageWeightValue_lbs-hint" class="govuk-hint">
49
-
50
- </div>
51
42
  <div class="govuk-input__wrapper">
52
- <input class="govuk-input govuk-input--width-5" id="luggageWeightValue_lbs" name="luggageWeightValue_lbs" type="text" spellcheck="false" value="" aria-describedby="luggageWeightValue_lbs-hint" inputmode="numeric">
43
+ <input class="govuk-input govuk-input--width-5" id="luggageWeightValue_lbs" name="luggageWeightValue_lbs" type="text" spellcheck="false" value="" inputmode="numeric">
53
44
  <div class="govuk-input__suffix" aria-hidden="true">lbs</div>
54
45
  </div>
55
46
  </div>
@@ -1,17 +1,12 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <h1 class="govuk-heading-l">How many nights will you stay on holiday?</h1>
4
- <p class="govuk-body"></p>
5
4
  <form action="" method="post" novalidate>
6
- <input type="hidden" name="_csrf" value="">
7
5
  <div class="govuk-form-group">
8
6
  <label class="govuk-label" for="nights">
9
7
  Nights
10
8
  </label>
11
- <div id="nights-hint" class="govuk-hint">
12
-
13
- </div>
14
- <input class="govuk-input govuk-input--width-5" id="nights" name="nights" type="text" spellcheck="false" value="" aria-describedby="nights-hint" inputmode="numeric">
9
+ <input class="govuk-input govuk-input--width-5" id="nights" name="nights" type="text" spellcheck="false" value="" inputmode="numeric">
15
10
  </div>
16
11
 
17
12
  <button type="submit" class="govuk-button" data-module="govuk-button" data-cy="button-save-and-continue">
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
  <h1 class="govuk-label-wrapper">
7
6
  <label class="govuk-label govuk-label--l" for="secretWish">
@@ -10,10 +10,7 @@
10
10
  Which class do you want to travel in?
11
11
  </label>
12
12
  </h1>
13
- <div id="travelClass-hint" class="govuk-hint">
14
-
15
- </div>
16
- <select class="govuk-select" id="travelClass" name="travelClass" aria-describedby="travelClass-hint">
13
+ <select class="govuk-select" id="travelClass" name="travelClass">
17
14
  <option value="economy" data-cy="answer-economy">Economy</option>
18
15
  <option value="business" data-cy="answer-business">Business</option>
19
16
  <option value="first" data-cy="answer-first">First Class</option>
@@ -1,7 +1,6 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <form action="" method="post" novalidate>
4
- <input type="hidden" name="_csrf" value="">
5
4
 
6
5
 
7
6
  <fieldset class="govuk-fieldset">
@@ -11,9 +10,6 @@
11
10
  </h1>
12
11
  </legend>
13
12
 
14
- <p class="govuk-body"></p>
15
-
16
-
17
13
  <div class="govuk-form-group">
18
14
  <div class="govuk-radios govuk-radios" data-module="govuk-radios">
19
15
  <div class="govuk-radios__item">