@planning-inspectorate/dynamic-forms 3.3.4 → 3.4.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.
Files changed (262) hide show
  1. package/.azure/pipelines/azure-pipelines-pr.yml +4 -0
  2. package/.azure/pipelines/release.yml +4 -0
  3. package/README.md +20 -9
  4. package/package.json +9 -3
  5. package/src/components/address/question.js +1 -10
  6. package/src/components/boolean/question.js +1 -1
  7. package/src/components/checkbox/question.js +2 -6
  8. package/src/components/date/question.js +1 -8
  9. package/src/components/date-period/question.js +1 -8
  10. package/src/components/email/question.js +4 -4
  11. package/src/components/multi-field-input/question.js +3 -3
  12. package/src/components/multi-field-input/question.test.js +1 -1
  13. package/src/components/number-entry/question.js +1 -5
  14. package/src/components/radio/question.js +1 -1
  15. package/src/components/select/question.js +1 -1
  16. package/src/components/single-line-input/question.js +0 -8
  17. package/src/components/text-entry/question.js +4 -4
  18. package/src/components/text-entry-redact/question.js +6 -16
  19. package/src/components/unit-option-entry/question.js +4 -11
  20. package/src/components/utils/component-types.js +18 -0
  21. package/src/index.js +72 -25
  22. package/src/middleware/redirect-to-unanswered-question.test.js +1 -1
  23. package/src/questions/options-question.js +5 -12
  24. package/src/questions/question-types.d.ts +3 -3
  25. package/src/questions/question.js +6 -6
  26. package/src/questions/questions.js +1 -1
  27. package/tsconfig.json +9 -1
  28. package/types/commitlint.config.d.ts +7 -0
  29. package/types/commitlint.config.d.ts.map +1 -0
  30. package/types/eslint.config.d.ts +95 -0
  31. package/types/eslint.config.d.ts.map +1 -0
  32. package/types/src/components/address/question.d.ts +31 -0
  33. package/types/src/components/address/question.d.ts.map +1 -0
  34. package/types/src/components/address/question.test.d.ts +2 -0
  35. package/types/src/components/address/question.test.d.ts.map +1 -0
  36. package/types/src/components/boolean/question.d.ts +47 -0
  37. package/types/src/components/boolean/question.d.ts.map +1 -0
  38. package/types/src/components/boolean/question.test.d.ts +2 -0
  39. package/types/src/components/boolean/question.test.d.ts.map +1 -0
  40. package/types/src/components/checkbox/question.d.ts +49 -0
  41. package/types/src/components/checkbox/question.d.ts.map +1 -0
  42. package/types/src/components/checkbox/question.test.d.ts +2 -0
  43. package/types/src/components/checkbox/question.test.d.ts.map +1 -0
  44. package/types/src/components/date/question.d.ts +22 -0
  45. package/types/src/components/date/question.d.ts.map +1 -0
  46. package/types/src/components/date/question.test.d.ts +2 -0
  47. package/types/src/components/date/question.test.d.ts.map +1 -0
  48. package/types/src/components/date-period/question.d.ts +29 -0
  49. package/types/src/components/date-period/question.d.ts.map +1 -0
  50. package/types/src/components/date-period/question.test.d.ts +2 -0
  51. package/types/src/components/date-period/question.test.d.ts.map +1 -0
  52. package/types/src/components/date-time/question.d.ts +24 -0
  53. package/types/src/components/date-time/question.d.ts.map +1 -0
  54. package/types/src/components/date-time/question.test.d.ts +2 -0
  55. package/types/src/components/date-time/question.test.d.ts.map +1 -0
  56. package/types/src/components/email/question.d.ts +30 -0
  57. package/types/src/components/email/question.d.ts.map +1 -0
  58. package/types/src/components/email/question.test.d.ts +2 -0
  59. package/types/src/components/email/question.test.d.ts.map +1 -0
  60. package/types/src/components/identifier/question.d.ts +15 -0
  61. package/types/src/components/identifier/question.d.ts.map +1 -0
  62. package/types/src/components/identifier/question.test.d.ts +2 -0
  63. package/types/src/components/identifier/question.test.d.ts.map +1 -0
  64. package/types/src/components/manage-list/manage-list-section.d.ts +16 -0
  65. package/types/src/components/manage-list/manage-list-section.d.ts.map +1 -0
  66. package/types/src/components/manage-list/manage-list-section.test.d.ts +2 -0
  67. package/types/src/components/manage-list/manage-list-section.test.d.ts.map +1 -0
  68. package/types/src/components/manage-list/question.d.ts +41 -0
  69. package/types/src/components/manage-list/question.d.ts.map +1 -0
  70. package/types/src/components/manage-list/question.test.d.ts +2 -0
  71. package/types/src/components/manage-list/question.test.d.ts.map +1 -0
  72. package/types/src/components/manage-list/utils.d.ts +18 -0
  73. package/types/src/components/manage-list/utils.d.ts.map +1 -0
  74. package/types/src/components/manage-list/utils.test.d.ts +2 -0
  75. package/types/src/components/manage-list/utils.test.d.ts.map +1 -0
  76. package/types/src/components/multi-field-input/question.d.ts +106 -0
  77. package/types/src/components/multi-field-input/question.d.ts.map +1 -0
  78. package/types/src/components/multi-field-input/question.test.d.ts +2 -0
  79. package/types/src/components/multi-field-input/question.test.d.ts.map +1 -0
  80. package/types/src/components/number-entry/question.d.ts +37 -0
  81. package/types/src/components/number-entry/question.d.ts.map +1 -0
  82. package/types/src/components/radio/question.d.ts +53 -0
  83. package/types/src/components/radio/question.d.ts.map +1 -0
  84. package/types/src/components/radio/question.test.d.ts +2 -0
  85. package/types/src/components/radio/question.test.d.ts.map +1 -0
  86. package/types/src/components/select/question.d.ts +51 -0
  87. package/types/src/components/select/question.d.ts.map +1 -0
  88. package/types/src/components/select/question.test.d.ts +2 -0
  89. package/types/src/components/select/question.test.d.ts.map +1 -0
  90. package/types/src/components/single-line-input/question.d.ts +18 -0
  91. package/types/src/components/single-line-input/question.d.ts.map +1 -0
  92. package/types/src/components/single-line-input/question.test.d.ts +2 -0
  93. package/types/src/components/single-line-input/question.test.d.ts.map +1 -0
  94. package/types/src/components/text-entry/question.d.ts +34 -0
  95. package/types/src/components/text-entry/question.d.ts.map +1 -0
  96. package/types/src/components/text-entry/question.test.d.ts +2 -0
  97. package/types/src/components/text-entry/question.test.d.ts.map +1 -0
  98. package/types/src/components/text-entry-redact/question.d.ts +42 -0
  99. package/types/src/components/text-entry-redact/question.d.ts.map +1 -0
  100. package/types/src/components/text-entry-redact/question.test.d.ts +2 -0
  101. package/types/src/components/text-entry-redact/question.test.d.ts.map +1 -0
  102. package/types/src/components/unit-option-entry/question.d.ts +83 -0
  103. package/types/src/components/unit-option-entry/question.d.ts.map +1 -0
  104. package/types/src/components/unit-option-entry/question.test.d.ts +2 -0
  105. package/types/src/components/unit-option-entry/question.test.d.ts.map +1 -0
  106. package/types/src/components/utils/component-types.d.ts +19 -0
  107. package/types/src/components/utils/component-types.d.ts.map +1 -0
  108. package/types/src/components/utils/persisted-number-answer.d.ts +2 -0
  109. package/types/src/components/utils/persisted-number-answer.d.ts.map +1 -0
  110. package/types/src/components/utils/question-has-answer.d.ts +17 -0
  111. package/types/src/components/utils/question-has-answer.d.ts.map +1 -0
  112. package/types/src/components/utils/question-has-answer.test.d.ts +2 -0
  113. package/types/src/components/utils/question-has-answer.test.d.ts.map +1 -0
  114. package/types/src/components/utils/question-utils.d.ts +15 -0
  115. package/types/src/components/utils/question-utils.d.ts.map +1 -0
  116. package/types/src/components/utils/question-utils.test.d.ts +2 -0
  117. package/types/src/components/utils/question-utils.test.d.ts.map +1 -0
  118. package/types/src/controller.d.ts +78 -0
  119. package/types/src/controller.d.ts.map +1 -0
  120. package/types/src/controller.test.d.ts +2 -0
  121. package/types/src/controller.test.d.ts.map +1 -0
  122. package/types/src/index.d.ts +54 -0
  123. package/types/src/index.d.ts.map +1 -0
  124. package/types/src/journey/journey-response.d.ts +32 -0
  125. package/types/src/journey/journey-response.d.ts.map +1 -0
  126. package/types/src/journey/journey-response.test.d.ts +2 -0
  127. package/types/src/journey/journey-response.test.d.ts.map +1 -0
  128. package/types/src/journey/journey.d.ts +144 -0
  129. package/types/src/journey/journey.d.ts.map +1 -0
  130. package/types/src/journey/journey.test.d.ts +2 -0
  131. package/types/src/journey/journey.test.d.ts.map +1 -0
  132. package/types/src/lib/address-utils.d.ts +6 -0
  133. package/types/src/lib/address-utils.d.ts.map +1 -0
  134. package/types/src/lib/address-utils.test.d.ts +2 -0
  135. package/types/src/lib/address-utils.test.d.ts.map +1 -0
  136. package/types/src/lib/address.d.ts +43 -0
  137. package/types/src/lib/address.d.ts.map +1 -0
  138. package/types/src/lib/address.test.d.ts +2 -0
  139. package/types/src/lib/address.test.d.ts.map +1 -0
  140. package/types/src/lib/date-utils.d.ts +60 -0
  141. package/types/src/lib/date-utils.d.ts.map +1 -0
  142. package/types/src/lib/date-utils.test.d.ts +2 -0
  143. package/types/src/lib/date-utils.test.d.ts.map +1 -0
  144. package/types/src/lib/session-answer-store.d.ts +84 -0
  145. package/types/src/lib/session-answer-store.d.ts.map +1 -0
  146. package/types/src/lib/session-answer-store.test.d.ts +2 -0
  147. package/types/src/lib/session-answer-store.test.d.ts.map +1 -0
  148. package/types/src/lib/utils.d.ts +19 -0
  149. package/types/src/lib/utils.d.ts.map +1 -0
  150. package/types/src/lib/utils.test.d.ts +2 -0
  151. package/types/src/lib/utils.test.d.ts.map +1 -0
  152. package/types/src/lib/uuid.d.ts +7 -0
  153. package/types/src/lib/uuid.d.ts.map +1 -0
  154. package/types/src/lib/uuid.test.d.ts +2 -0
  155. package/types/src/lib/uuid.test.d.ts.map +1 -0
  156. package/types/src/middleware/build-get-journey.d.ts +6 -0
  157. package/types/src/middleware/build-get-journey.d.ts.map +1 -0
  158. package/types/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
  159. package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
  160. package/types/src/middleware/redirect-to-unanswered-question.test.d.ts +2 -0
  161. package/types/src/middleware/redirect-to-unanswered-question.test.d.ts.map +1 -0
  162. package/types/src/questions/create-questions.d.ts +21 -0
  163. package/types/src/questions/create-questions.d.ts.map +1 -0
  164. package/types/src/questions/options-question.d.ts +74 -0
  165. package/types/src/questions/options-question.d.ts.map +1 -0
  166. package/types/src/questions/options-question.test.d.ts +2 -0
  167. package/types/src/questions/options-question.test.d.ts.map +1 -0
  168. package/types/src/questions/question.d.ts +274 -0
  169. package/types/src/questions/question.d.ts.map +1 -0
  170. package/types/src/questions/question.test.d.ts +2 -0
  171. package/types/src/questions/question.test.d.ts.map +1 -0
  172. package/types/src/questions/questions.d.ts +3 -0
  173. package/types/src/questions/questions.d.ts.map +1 -0
  174. package/types/src/section.d.ts +107 -0
  175. package/types/src/section.d.ts.map +1 -0
  176. package/types/src/section.test.d.ts +2 -0
  177. package/types/src/section.test.d.ts.map +1 -0
  178. package/types/src/validator/address-validator.d.ts +41 -0
  179. package/types/src/validator/address-validator.d.ts.map +1 -0
  180. package/types/src/validator/address-validator.test.d.ts +2 -0
  181. package/types/src/validator/address-validator.test.d.ts.map +1 -0
  182. package/types/src/validator/base-validator.d.ts +11 -0
  183. package/types/src/validator/base-validator.d.ts.map +1 -0
  184. package/types/src/validator/base-validator.test.d.ts +2 -0
  185. package/types/src/validator/base-validator.test.d.ts.map +1 -0
  186. package/types/src/validator/conditional-required-validator.d.ts +24 -0
  187. package/types/src/validator/conditional-required-validator.d.ts.map +1 -0
  188. package/types/src/validator/conditional-required-validator.test.d.ts +2 -0
  189. package/types/src/validator/conditional-required-validator.test.d.ts.map +1 -0
  190. package/types/src/validator/confirmation-checkbox-validator.d.ts +27 -0
  191. package/types/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
  192. package/types/src/validator/confirmation-checkbox-validator.test.d.ts +2 -0
  193. package/types/src/validator/confirmation-checkbox-validator.test.d.ts.map +1 -0
  194. package/types/src/validator/coordinates-validator.d.ts +22 -0
  195. package/types/src/validator/coordinates-validator.d.ts.map +1 -0
  196. package/types/src/validator/coordinates-validator.test.d.ts +2 -0
  197. package/types/src/validator/coordinates-validator.test.d.ts.map +1 -0
  198. package/types/src/validator/date-period-validator.d.ts +63 -0
  199. package/types/src/validator/date-period-validator.d.ts.map +1 -0
  200. package/types/src/validator/date-period-validator.test.d.ts +2 -0
  201. package/types/src/validator/date-period-validator.test.d.ts.map +1 -0
  202. package/types/src/validator/date-time-validator.d.ts +26 -0
  203. package/types/src/validator/date-time-validator.d.ts.map +1 -0
  204. package/types/src/validator/date-time-validator.test.d.ts +2 -0
  205. package/types/src/validator/date-time-validator.test.d.ts.map +1 -0
  206. package/types/src/validator/date-validator.d.ts +48 -0
  207. package/types/src/validator/date-validator.d.ts.map +1 -0
  208. package/types/src/validator/date-validator.test.d.ts +2 -0
  209. package/types/src/validator/date-validator.test.d.ts.map +1 -0
  210. package/types/src/validator/document-upload-validator.d.ts +10 -0
  211. package/types/src/validator/document-upload-validator.d.ts.map +1 -0
  212. package/types/src/validator/document-upload-validator.test.d.ts +2 -0
  213. package/types/src/validator/document-upload-validator.test.d.ts.map +1 -0
  214. package/types/src/validator/email-validator.d.ts +73 -0
  215. package/types/src/validator/email-validator.d.ts.map +1 -0
  216. package/types/src/validator/email-validator.test.d.ts +2 -0
  217. package/types/src/validator/email-validator.test.d.ts.map +1 -0
  218. package/types/src/validator/multi-field-input-validator.d.ts +70 -0
  219. package/types/src/validator/multi-field-input-validator.d.ts.map +1 -0
  220. package/types/src/validator/multi-field-input-validator.test.d.ts +2 -0
  221. package/types/src/validator/multi-field-input-validator.test.d.ts.map +1 -0
  222. package/types/src/validator/numeric-validator.d.ts +49 -0
  223. package/types/src/validator/numeric-validator.d.ts.map +1 -0
  224. package/types/src/validator/numeric-validator.test.d.ts +2 -0
  225. package/types/src/validator/numeric-validator.test.d.ts.map +1 -0
  226. package/types/src/validator/required-validator.d.ts +22 -0
  227. package/types/src/validator/required-validator.d.ts.map +1 -0
  228. package/types/src/validator/required-validator.test.d.ts +2 -0
  229. package/types/src/validator/required-validator.test.d.ts.map +1 -0
  230. package/types/src/validator/same-answer-validator.d.ts +18 -0
  231. package/types/src/validator/same-answer-validator.d.ts.map +1 -0
  232. package/types/src/validator/same-answer-validator.test.d.ts +2 -0
  233. package/types/src/validator/same-answer-validator.test.d.ts.map +1 -0
  234. package/types/src/validator/string-validator.d.ts +58 -0
  235. package/types/src/validator/string-validator.d.ts.map +1 -0
  236. package/types/src/validator/string-validator.test.d.ts +2 -0
  237. package/types/src/validator/string-validator.test.d.ts.map +1 -0
  238. package/types/src/validator/unit-option-entry-validator.d.ts +40 -0
  239. package/types/src/validator/unit-option-entry-validator.d.ts.map +1 -0
  240. package/types/src/validator/unit-option-entry-validator.test.d.ts +2 -0
  241. package/types/src/validator/unit-option-entry-validator.test.d.ts.map +1 -0
  242. package/types/src/validator/valid-option-validator.d.ts +22 -0
  243. package/types/src/validator/valid-option-validator.d.ts.map +1 -0
  244. package/types/src/validator/valid-option-validator.test.d.ts +2 -0
  245. package/types/src/validator/valid-option-validator.test.d.ts.map +1 -0
  246. package/types/src/validator/validation-error-handler.d.ts +20 -0
  247. package/types/src/validator/validation-error-handler.d.ts.map +1 -0
  248. package/types/src/validator/validation-error-handler.test.d.ts +2 -0
  249. package/types/src/validator/validation-error-handler.test.d.ts.map +1 -0
  250. package/types/src/validator/validator.d.ts +5 -0
  251. package/types/src/validator/validator.d.ts.map +1 -0
  252. package/types/src/validator/validator.test.d.ts +2 -0
  253. package/types/src/validator/validator.test.d.ts.map +1 -0
  254. package/types/test/mock/journey.d.ts +3 -0
  255. package/types/test/mock/journey.d.ts.map +1 -0
  256. package/types/test/mock/uuid.d.ts +7 -0
  257. package/types/test/mock/uuid.d.ts.map +1 -0
  258. package/types/test/utils/nunjucks.d.ts +2 -0
  259. package/types/test/utils/nunjucks.d.ts.map +1 -0
  260. package/types/test/utils/utils.d.ts +32 -0
  261. package/types/test/utils/utils.d.ts.map +1 -0
  262. package/src/lib/address.d.ts +0 -7
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {(req: import('express').Request, journeyResponse: import('../journey/journey-response.js').JourneyResponse) => import('../journey/journey.js').Journey} createJourney
3
+ * @returns {import('express').Handler}
4
+ */
5
+ export function buildGetJourney(createJourney: (req: any, journeyResponse: import("../journey/journey-response.js").JourneyResponse) => import("../journey/journey.js").Journey): any;
6
+ //# sourceMappingURL=build-get-journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-get-journey.d.ts","sourceRoot":"","sources":["../../../src/middleware/build-get-journey.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+CAHW,CAAC,GAAG,EAAE,GAAyB,EAAE,eAAe,EAAE,OAAO,gCAAgC,EAAE,eAAe,KAAK,OAAO,uBAAuB,EAAE,OAAO,OAiBhK"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @typedef {function(import('../section').Question, import('../journey/journey-response').JourneyResponse): boolean} ShouldDisplayCondition
3
+ */
4
+ /**
5
+ * Redirects to the first unanswered question in a journey, or to the task list if complete
6
+ *
7
+ * @param {ShouldDisplayCondition[]} [conditions]
8
+ * @returns {import('express').Handler}
9
+ */
10
+ export function redirectToUnansweredQuestion(conditions?: ShouldDisplayCondition[]): any;
11
+ export type ShouldDisplayCondition = (arg0: any, arg1: any) => boolean;
12
+ //# sourceMappingURL=redirect-to-unanswered-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-to-unanswered-question.d.ts","sourceRoot":"","sources":["../../../src/middleware/redirect-to-unanswered-question.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,0DAHW,sBAAsB,EAAE,OA+BlC;qCArCY,CAAS,IAA6B,EAA7B,GAA6B,EAAE,IAAqD,EAArD,GAAqD,KAAG,OAAO"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=redirect-to-unanswered-question.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-to-unanswered-question.test.d.ts","sourceRoot":"","sources":["../../../src/middleware/redirect-to-unanswered-question.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /** @typedef {import('./question-props').QuestionProps} QuestionProps */
2
+ /**
3
+ * @param {{[questionName: string]: QuestionProps}} questionPropsRecord
4
+ * @param {Record<string, typeof import('./question').Question>} questionClasses
5
+ * @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
6
+ * @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
7
+ */
8
+ export function createQuestions(questionPropsRecord: {
9
+ [questionName: string]: QuestionProps;
10
+ }, questionClasses: Record<string, typeof import("./question").Question>, questionMethodOverrides: {
11
+ [questionType: string]: Record<string, Function>;
12
+ }, textOverrides?: {
13
+ notStartedText?: string;
14
+ continueButtonText?: string;
15
+ changeActionText?: string;
16
+ answerActionText?: string;
17
+ }): {
18
+ [k: string]: any;
19
+ };
20
+ export type QuestionProps = any;
21
+ //# sourceMappingURL=create-questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-questions.d.ts","sourceRoot":"","sources":["../../../src/questions/create-questions.js"],"names":[],"mappings":"AAAA,wEAAwE;AAExE;;;;;GAKG;AACH,qDALW;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAAA;CAAC,mBACvC,MAAM,CAAC,MAAM,EAAE,cAAc,YAAY,EAAE,QAAQ,CAAC,2BACpD;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,WAAW,CAAA;CAAC,kBAClD;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAC;;EAwBtH"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @typedef {{
3
+ * text: string;
4
+ * value: string;
5
+ * hint?: object;
6
+ * checked?: boolean | undefined;
7
+ * attributes?: Record<string, string>;
8
+ * behaviour?: 'exclusive';
9
+ * conditional?: {
10
+ * question: string;
11
+ * type: string;
12
+ * fieldName: string;
13
+ * inputClasses?: string;
14
+ * html?: string;
15
+ * value?: unknown;
16
+ * label?: string;
17
+ * hint?: string
18
+ * };
19
+ * conditionalText?: {
20
+ * html: string;
21
+ * }
22
+ *}} Option
23
+ */
24
+ /**
25
+ * @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
26
+ */
27
+ export default class OptionsQuestion extends Question {
28
+ /**
29
+ * @param {import('#question-types').QuestionParameters} params
30
+ * @param {Array<Option>} params.options
31
+ */
32
+ constructor(params: import("#question-types").QuestionParameters);
33
+ /** @type {Array<Option>} */
34
+ options: Array<Option>;
35
+ optionJoinString: string;
36
+ /**
37
+ * gets the view model for this question
38
+ * @param {import('#section').Section} section - the current section
39
+ * @param {import('#journey').Journey} journey - the journey we are in
40
+ * @param {Record<string, unknown>} [customViewData] additional data to send to view
41
+ * @param {Record<string, unknown>} [payload]
42
+ * @param {import('#src/questions/question-types.d.ts').PrepQuestionForRenderingOptions} options
43
+ * @returns {import('./question').QuestionViewModel} QuestionViewModel
44
+ */
45
+ prepQuestionForRendering(section: import("#section").Section, journey: import("#journey").Journey, customViewData?: Record<string, unknown>, payload?: Record<string, unknown>, options: import("#src/questions/question-types.d.ts").PrepQuestionForRenderingOptions): any;
46
+ }
47
+ export type Option = {
48
+ text: string;
49
+ value: string;
50
+ hint?: object;
51
+ checked?: boolean | undefined;
52
+ attributes?: Record<string, string>;
53
+ behaviour?: "exclusive";
54
+ conditional?: {
55
+ question: string;
56
+ type: string;
57
+ fieldName: string;
58
+ inputClasses?: string;
59
+ html?: string;
60
+ value?: unknown;
61
+ label?: string;
62
+ hint?: string;
63
+ };
64
+ conditionalText?: {
65
+ html: string;
66
+ };
67
+ };
68
+ export type OptionsViewModel = any & {
69
+ question: {
70
+ options: Option[];
71
+ };
72
+ };
73
+ import { Question } from './question.js';
74
+ //# sourceMappingURL=options-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-question.d.ts","sourceRoot":"","sources":["../../../src/questions/options-question.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AAEH;IAIC;;;OAGG;IACH,oBAHW,OAAO,iBAAiB,EAAE,kBAAkB,EAgBtD;IApBD,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CAChB;IAkBP,yBAA+C;IAGhD;;;;;;;;OAQG;IACH,kCAPW,OAAO,UAAU,EAAE,OAAO,WAC1B,OAAO,UAAU,EAAE,OAAO,mBAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACvB,OAAO,oCAAoC,EAAE,+BAA+B,OAmDtF;CAmCD;qBA9IY;IACR,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;KAClB,CAAC;IACA,eAAe,CAAC,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAA;CACH;+BAIU,GAAsC,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE;yBA/BhE,eAAe"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=options-question.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-question.test.d.ts","sourceRoot":"","sources":["../../../src/questions/options-question.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,274 @@
1
+ /**
2
+ * @import {BaseValidator} from "#base-validator"
3
+ * @import {Journey} from "#journey"
4
+ * @import {JourneyResponse} from "#journey-response"
5
+ * @import {Section} from "#section"
6
+ * @import {ActionView} from "../controller.js"
7
+ * @import {ActionLink} from "./question-types.js"
8
+ */
9
+ /**
10
+ * @typedef {Object} PreppedQuestion
11
+ * @property {Object} value
12
+ * @property {string} question
13
+ * @property {string} fieldName
14
+ * @property {string} pageTitle
15
+ * @property {string} [description]
16
+ * @property {string} [html]
17
+ */
18
+ /**
19
+ * @typedef {Record<string, any>} QuestionViewModel
20
+ * @property {PreppedQuestion} question
21
+ * @property {string} layoutTemplate
22
+ * @property {string} pageCaption
23
+ * @property {string} [continueButtonText]
24
+ * @property {string} backLink
25
+ * @property {boolean} showBackToListLink
26
+ * @property {string} listLink
27
+ * @property {Object} util
28
+ * @property {function(string): string} util.trimTrailingSlash
29
+ */
30
+ /**
31
+ * A specific question within a journey which is made up of one (usually) or many (sometimes) components and their required content.
32
+ * @class
33
+ */
34
+ export class Question {
35
+ /**
36
+ * @param {import('#question-types').QuestionParameters} params
37
+ * @param {Record<string, Function>} [methodOverrides]
38
+ */
39
+ constructor({ title, question, viewFolder, fieldName, url, pageTitle, description, validators, html, hint, interfaceType, shouldDisplay, autocomplete, editable, actionLink, viewData }: import("#question-types").QuestionParameters, methodOverrides?: Record<string, Function>);
40
+ /** @type {string} - html page title, defaults to question if not provided */
41
+ pageTitle: string;
42
+ /** @type {string} - title used in the summary list */
43
+ title: string;
44
+ /** @type {string} - question shown to user on question page */
45
+ question: string;
46
+ /** @type {string|undefined} - additional information to user about the question */
47
+ description: string | undefined;
48
+ /** @type {string} the folder name of the view */
49
+ viewFolder: string;
50
+ /** @type {string} the unique name of the input on the page, also used as a url segment (should this be separated) */
51
+ fieldName: string;
52
+ /** @type {boolean} if the question should appear in the journey overview task list or not */
53
+ taskList: boolean;
54
+ /** @type {Array.<BaseValidator>} array of validators that a question uses to validate answers */
55
+ validators: Array<escape>;
56
+ /** @type {string|undefined} hint text displayed to user */
57
+ hint: string | undefined;
58
+ /** @type {boolean} show return to listing page link after question */
59
+ showBackToListLink: boolean;
60
+ /** @type {string|undefined} alternative url slug */
61
+ url: string | undefined;
62
+ /** @type {string|undefined} optional html content */
63
+ html: string | undefined;
64
+ /** @type {string|undefined} optional question type */
65
+ interfaceType: string | undefined;
66
+ /** @type {ActionLink|undefined} override action link */
67
+ actionLink: ActionLink | undefined;
68
+ /** @type {string} 'not started' text to display (if a question has no answer) */
69
+ notStartedText: string;
70
+ /** @type {string} button text to display */
71
+ continueButtonText: string;
72
+ /** @type {string} text to display for 'change' link */
73
+ changeActionText: string;
74
+ /** @type {string} text to display for 'answer' link */
75
+ answerActionText: string;
76
+ /** @type {string} text to display for 'add' link */
77
+ addActionText: string;
78
+ /**
79
+ * @param {JourneyResponse} [response]
80
+ * @returns {boolean}
81
+ */
82
+ shouldDisplay: () => boolean;
83
+ details: {
84
+ title: string;
85
+ text: string;
86
+ };
87
+ autocomplete: string | undefined;
88
+ editable: boolean;
89
+ viewData: Record<string, any>;
90
+ /**
91
+ * Is this question a manage list question?
92
+ * Implemented as a getter so manage list question implementations can override it,
93
+ * but it cannot be changed at runtime.
94
+ *
95
+ * @returns {boolean}
96
+ */
97
+ get isManageListQuestion(): boolean;
98
+ set isInManageListSection(value: boolean);
99
+ /**
100
+ * Is this question added to a ManageListSection?
101
+ *
102
+ * @returns {boolean}
103
+ */
104
+ get isInManageListSection(): boolean;
105
+ /**
106
+ * gets the view model for this question
107
+ *
108
+ * Wraps prepQuestionForRendering to add the back link - which requires more parameters
109
+ * that prepQuestionForRendering doesn't need
110
+ *
111
+ * @param {Object} options
112
+ * @param {import('#src/journey/journey-types.d.ts').RouteParams} options.params
113
+ * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
114
+ * @param {Section} options.section - the current section
115
+ * @param {Journey} options.journey - the journey we are in
116
+ * @param {Record<string, unknown>} [options.customViewData] additional data to send to view
117
+ * @param {unknown} [options.payload]
118
+ * @returns {QuestionViewModel}
119
+ */
120
+ toViewModel({ params, manageListQuestion, section, journey, customViewData, payload }: {
121
+ params: import("#src/journey/journey-types.d.ts").RouteParams;
122
+ manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
123
+ section: Section;
124
+ journey: Journey;
125
+ customViewData?: Record<string, unknown> | undefined;
126
+ payload?: unknown;
127
+ }): QuestionViewModel;
128
+ /**
129
+ * gets the base view model for this question
130
+ *
131
+ * @param {Section} section - the current section
132
+ * @param {Journey} journey - the journey we are in
133
+ * @param {Record<string, unknown>} [customViewData] additional data to send to view
134
+ * @param {unknown} [payload]
135
+ * @param {import('./question-types.d.ts').PrepQuestionForRenderingOptions} [options] - required to support manage list question
136
+ * @returns {QuestionViewModel}
137
+ */
138
+ prepQuestionForRendering(section: Section, journey: Journey, customViewData?: Record<string, unknown>, payload?: unknown, options?: import("./question-types.d.ts").PrepQuestionForRenderingOptions): QuestionViewModel;
139
+ /**
140
+ * The answer to this question for use in the viewModel
141
+ *
142
+ * Question implementations can override this for more complex answer types
143
+ *
144
+ * @param {Record<string, any>} answers - collection of answers to pull the answer from, may be from the response or the request/payload
145
+ * @param {Boolean} isPayload - whether the answers object is from the request/payload
146
+ * @returns {*|string}
147
+ */ answerForViewModel(answers: Record<string, any>, isPayload: boolean): any | string;
148
+ /**
149
+ * Question implementations can override this to add configuration or other values to the view model
150
+ *
151
+ * If possible override this method instead of prepQuestionForRendering for simple changes to the view model
152
+ *
153
+ * @param {QuestionViewModel} viewModel
154
+ */ addCustomDataToViewModel(viewModel: QuestionViewModel): void;
155
+ /**
156
+ * Get the answers object from the journey response, which may be nested in an array for manage list questions
157
+ *
158
+ * @param {JourneyResponse} response
159
+ * @param {import('./question-types.d.ts').PrepQuestionForRenderingOptions} [options]
160
+ * @returns {Record<string, any>}
161
+ */
162
+ answerObjectFromJourneyResponse(response: JourneyResponse, { params, manageListQuestion }?: import("./question-types.d.ts").PrepQuestionForRenderingOptions): Record<string, any>;
163
+ /**
164
+ * renders the question
165
+ * @param {import('express').Response} res - the express response
166
+ * @param {QuestionViewModel} viewModel additional data to send to view
167
+ * @returns {void}
168
+ */
169
+ renderAction(res: any, viewModel: QuestionViewModel): void;
170
+ /**
171
+ * check for validation errors
172
+ * @param {import('express').Request} req
173
+ * @param {Journey} journey
174
+ * @param {Section} section
175
+ * @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
176
+ * @returns {QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
177
+ */
178
+ checkForValidationErrors(req: any, section: Section, journey: Journey, manageListQuestion?: typeof import("#src/components/manage-list/question.js")): QuestionViewModel | undefined;
179
+ /**
180
+ * Get the data to save from the request, returns an object of answers
181
+ *
182
+ * @param {import('express').Request} req
183
+ * @param {JourneyResponse} journeyResponse - current journey response
184
+ * @returns {Promise<{ answers: Record<string, unknown> }>}
185
+ */ getDataToSave(req: any, journeyResponse: JourneyResponse): Promise<{
186
+ answers: Record<string, unknown>;
187
+ }>;
188
+ /**
189
+ * check for errors after saving, by default this does nothing
190
+ * @param {import('express').Request} req
191
+ * @param {Journey} journey
192
+ * @param {Section} sectionObj
193
+ * @returns {QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
194
+ */ checkForSavingErrors(req: any, sectionObj: Section, journey: Journey): QuestionViewModel | undefined;
195
+ /**
196
+ * Handles redirect after saving. Kept around for backwards compatibility.
197
+ *
198
+ * @param {import('express').Response} res
199
+ * @param {Journey} journey
200
+ * @param {string} sectionSegment
201
+ * @param {string} questionSegment
202
+ * @returns {void}
203
+ * @deprecated - use `journey.redirectToNextQuestion`
204
+ */
205
+ handleNextQuestion(res: any, journey: Journey, sectionSegment: string, questionSegment: string): void;
206
+ /**
207
+ * returns the formatted answers values to be used to build task list elements
208
+ * @param {String} sectionSegment
209
+ * @param {Journey} journey
210
+ * @param {Object} answer
211
+ * @returns {Array<{
212
+ * key: string;
213
+ * value: string | Object;
214
+ * action: {
215
+ * href: string;
216
+ * text: string;
217
+ * visuallyHiddenText: string;
218
+ * };
219
+ * }>}
220
+ */
221
+ formatAnswerForSummary(sectionSegment: string, journey: Journey, answer: Object, capitals?: boolean): Array<{
222
+ key: string;
223
+ value: string | Object;
224
+ action: {
225
+ href: string;
226
+ text: string;
227
+ visuallyHiddenText: string;
228
+ };
229
+ }>;
230
+ /**
231
+ * Returns the action link for the question
232
+ * @param {Object} answer
233
+ * @param {Journey} journey
234
+ * @param {String} sectionSegment
235
+ * @returns {ActionView|ActionView[]|undefined}
236
+ */
237
+ getAction(sectionSegment: string, journey: Journey, answer: Object): ActionView | ActionView[] | undefined;
238
+ /**
239
+ * @param {unknown} answer
240
+ * @returns {unknown}
241
+ */
242
+ format(answer: unknown): unknown;
243
+ /**
244
+ * @returns {boolean}
245
+ */
246
+ isRequired(): boolean;
247
+ /**
248
+ * @param {string} inputField
249
+ * @returns {boolean}
250
+ */
251
+ fieldIsRequired(inputField: string): boolean;
252
+ /**
253
+ * @param {JourneyResponse} journeyResponse
254
+ * @param {string} [fieldName] optional fieldname for multi field input questions
255
+ * @returns {boolean}
256
+ */
257
+ isAnswered(journeyResponse: JourneyResponse, fieldName?: string): boolean;
258
+ #private;
259
+ }
260
+ export type PreppedQuestion = {
261
+ value: Object;
262
+ question: string;
263
+ fieldName: string;
264
+ pageTitle: string;
265
+ description?: string | undefined;
266
+ html?: string | undefined;
267
+ };
268
+ export type QuestionViewModel = Record<string, any>;
269
+ import type { ActionLink } from "./question-types.js";
270
+ import type { Section } from "#section";
271
+ import type { Journey } from "#journey";
272
+ import type { JourneyResponse } from "#journey-response";
273
+ import type { ActionView } from "../controller.js";
274
+ //# sourceMappingURL=question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../src/questions/question.js"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=question.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../src/questions/question.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** @type {Record<string, import('./question').Question>} */
2
+ export const questionClasses: Record<string, any>;
3
+ //# sourceMappingURL=questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../../src/questions/questions.js"],"names":[],"mappings":"AAsBA,4DAA4D;AAC5D,8BADW,MAAM,CAAC,MAAM,EAAE,GAA6B,CAAC,CAkBrD"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * A value indicating the final question of a section has been reached
3
+ *
4
+ * @type {Symbol}
5
+ */
6
+ export const END_OF_SECTION: Symbol;
7
+ /**
8
+ * Defines a section for a questionnaire, a set of Questions
9
+ * @class
10
+ */
11
+ export class Section {
12
+ /**
13
+ * Implementation of getNextQuestion given a list of questions
14
+ *
15
+ * @param {import('./section-types.d.ts').StaticGetNextQuestionParams} params
16
+ * @returns {Question|Symbol|null}
17
+ */
18
+ static getNextQuestion({ questions, questionFieldName, response, takeNextQuestion, reverse }: import("./section-types.d.ts").StaticGetNextQuestionParams): Question | Symbol | null;
19
+ /**
20
+ * creates an instance of a section
21
+ * @param {string} name
22
+ * @param {string} segment
23
+ */
24
+ constructor(name: string, segment: string);
25
+ /**
26
+ * @type {string} - the display name of the section shown to user
27
+ */
28
+ name: string;
29
+ /**
30
+ * @type {string} - the unique url segment for the section
31
+ */
32
+ segment: string;
33
+ /**
34
+ * @type {Array<Question>} - questions within the section
35
+ */
36
+ questions: Array<Question>;
37
+ /**
38
+ * Add a condition to all questions in this section
39
+ *
40
+ * @param {QuestionCondition} shouldIncludeSection
41
+ * @returns {Section}
42
+ */
43
+ withSectionCondition(shouldIncludeSection: QuestionCondition): Section;
44
+ /**
45
+ * Fluent API method for adding questions
46
+ * @param {import('#src/questions/question.js').Question} question
47
+ * @param {import('#src/components/manage-list/manage-list-section.js').ManageListSection} [manageListSection]
48
+ * @returns {Section}
49
+ */
50
+ addQuestion(question: import("#src/questions/question.js").Question, manageListSection?: import("#src/components/manage-list/manage-list-section.js").ManageListSection): Section;
51
+ /**
52
+ * Fluent API method for attaching conditions to the previously added question
53
+ * @param {QuestionCondition} shouldIncludeQuestion
54
+ * @returns {Section}
55
+ */
56
+ withCondition(shouldIncludeQuestion: QuestionCondition): Section;
57
+ withRequiredCondition(isQuestionMandatory: any, requiredFieldErrorMsg: any): this;
58
+ /**
59
+ * Fluent API method for starting a multi question condition
60
+ * @param {string} conditionName
61
+ * @param {QuestionCondition} shouldIncludeQuestion
62
+ * @returns {Section}
63
+ */
64
+ startMultiQuestionCondition(conditionName: string, shouldIncludeQuestion: QuestionCondition): Section;
65
+ /**
66
+ * Fluent API method for ending a multi question condition
67
+ * @param {string} conditionName
68
+ * @returns {Section}
69
+ */
70
+ endMultiQuestionCondition(conditionName: string): Section;
71
+ /**
72
+ * Get the next question in this section given a questionParam (question fieldName)
73
+ * @param {import('./section-types.d.ts').GetNextQuestionParams} params
74
+ * @returns {Question|Symbol|null}
75
+ */
76
+ getNextQuestion(params: import("./section-types.d.ts").GetNextQuestionParams): Question | Symbol | null;
77
+ /**
78
+ * checks answers on response to ensure that a answer is provided for each required question in the section
79
+ * @param {JourneyResponse} journeyResponse
80
+ * @returns {SectionStatus}
81
+ */
82
+ getStatus(journeyResponse: JourneyResponse): SectionStatus;
83
+ /**
84
+ * checks answers on response and return true if the status of the section is complete
85
+ * @param {JourneyResponse} journeyResponse
86
+ * @returns {boolean}
87
+ */
88
+ isComplete(journeyResponse: JourneyResponse): boolean;
89
+ #private;
90
+ }
91
+ export type SECTION_STATUS = SectionStatus;
92
+ /**
93
+ * @typedef {string} SectionStatus
94
+ */
95
+ /**
96
+ * @enum {SectionStatus}
97
+ */
98
+ export const SECTION_STATUS: Readonly<{
99
+ NOT_STARTED: "Not started";
100
+ IN_PROGRESS: "In progress";
101
+ COMPLETE: "Completed";
102
+ }>;
103
+ export type Question = any;
104
+ export type JourneyResponse = any;
105
+ export type QuestionCondition = ((response: JourneyResponse) => boolean);
106
+ export type SectionStatus = string;
107
+ //# sourceMappingURL=section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../../src/section.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH,6BAFU,MAAM,CAEuC;AAEvD;;;GAGG;AACH;IAgNC;;;;;OAKG;IACH,8FAHW,OAAO,sBAAsB,EAAE,2BAA2B,GACxD,QAAQ,GAAC,MAAM,GAAC,IAAI,CAoBhC;IAvMD;;;;OAIG;IACH,kBAHW,MAAM,WACN,MAAM,EAKhB;IAxCD;;OAEG;IACH,MAFU,MAAM,CAEX;IAEL;;OAEG;IACH,SAFU,MAAM,CAER;IAER;;OAEG;IACH,WAFU,KAAK,CAAC,QAAQ,CAAC,CAEV;IA6Bf;;;;;OAKG;IACH,2CAHW,iBAAiB,GACf,OAAO,CAcnB;IAED;;;;;OAKG;IACH,sBAJW,OAAO,4BAA4B,EAAE,QAAQ,sBAC7C,OAAO,oDAAoD,EAAE,iBAAiB,GAC5E,OAAO,CAgBnB;IA8BD;;;;OAIG;IACH,qCAHW,iBAAiB,GACf,OAAO,CAanB;IAED,kFAoBC;IAED;;;;;OAKG;IACH,2CAJW,MAAM,yBACN,iBAAiB,GACf,OAAO,CAQnB;IAED;;;;OAIG;IACH,yCAHW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;OAIG;IACH,wBAHW,OAAO,sBAAsB,EAAE,qBAAqB,GAClD,QAAQ,GAAC,MAAM,GAAC,IAAI,CAuBhC;IA4BD;;;;OAIG;IACH,2BAHW,eAAe,GACb,aAAa,CAoDzB;IAED;;;;OAIG;IACH,4BAHW,eAAe,GACb,OAAO,CAInB;;CAKD;6BAOS,aAAa;AALvB;;GAEG;AAEH;;GAEG;AACH;;;;GAIG;;;gCA7UU,CAAC,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC;4BAmUxC,MAAM"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=section.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.test.d.ts","sourceRoot":"","sources":["../../src/section.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ export function validatePostcode(postcode: any, errorMessage?: string): any;
2
+ export const addressLine1MaxLength: 250;
3
+ export const addressLine1MinLength: 0;
4
+ export const addressLine2MaxLength: 250;
5
+ export const addressLine2MinLength: 0;
6
+ export const townCityMaxLength: 250;
7
+ export const townCityMinLength: 0;
8
+ export const countyMaxLength: 250;
9
+ export const countyMinLength: 0;
10
+ export const postcodeMaxLength: 8;
11
+ export const postcodeMinLength: 5;
12
+ /**
13
+ * enforces address fields are within allowed parameters
14
+ * @class
15
+ */
16
+ export default class AddressValidator extends BaseValidator {
17
+ /**
18
+ * creates an instance of an AddressValidator
19
+ * @param {Object} opts
20
+ * @param {boolean} [opts.required]
21
+ * @param {{[key: string]: boolean}} [opts.requiredFields]
22
+ */
23
+ constructor(opts: {
24
+ required?: boolean | undefined;
25
+ requiredFields?: {
26
+ [key: string]: boolean;
27
+ } | undefined;
28
+ });
29
+ requiredFields: {
30
+ [key: string]: boolean;
31
+ } | undefined;
32
+ /**
33
+ * validates response body using questionObj fieldname
34
+ * @param {Question} questionObj
35
+ */
36
+ validate(questionObj: Question): import("express-validator").ValidationChain[];
37
+ isRequired(): boolean;
38
+ #private;
39
+ }
40
+ import BaseValidator from './base-validator.js';
41
+ //# sourceMappingURL=address-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-validator.d.ts","sourceRoot":"","sources":["../../../src/validator/address-validator.js"],"names":[],"mappings":"AAIO,4EAQN;AAGD,oCAAqC,GAAG,CAAC;AACzC,oCAAqC,CAAC,CAAC;AACvC,oCAAqC,GAAG,CAAC;AACzC,oCAAqC,CAAC,CAAC;AACvC,gCAAiC,GAAG,CAAC;AACrC,gCAAiC,CAAC,CAAC;AACnC,8BAA+B,GAAG,CAAC;AACnC,8BAA+B,CAAC,CAAC;AACjC,gCAAiC,CAAC,CAAC;AACnC,gCAAiC,CAAC,CAAC;AAEnC;;;GAGG;AACH;IACC;;;;;OAKG;IACH,kBAHG;QAAuB,QAAQ;QACS,cAAc;;;KAAC,EAKzD;IADA;;kBAA0C;IAG3C;;;OAGG;IACH,sBAFW,QAAQ,iDAYlB;IA+FD,sBAKC;;CACD;0BA3JyB,qBAAqB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=address-validator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-validator.test.d.ts","sourceRoot":"","sources":["../../../src/validator/address-validator.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @abstract
3
+ * @class BaseValidator
4
+ */
5
+ export default class BaseValidator {
6
+ /**
7
+ * @type {string} error message to display to user
8
+ */
9
+ errorMessage: string;
10
+ }
11
+ //# sourceMappingURL=base-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-validator.d.ts","sourceRoot":"","sources":["../../../src/validator/base-validator.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACC;;OAEG;IACH,cAFU,MAAM,CAEH;CAOb"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base-validator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-validator.test.d.ts","sourceRoot":"","sources":["../../../src/validator/base-validator.test.js"],"names":[],"mappings":""}