@defra/fcp-sfd-frontend-engine 0.3.0 → 0.5.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/dist/index.cjs +384 -7
- package/dist/index.js +384 -7
- package/package.json +1 -1
- package/src/constants/index.js +16 -0
- package/src/constants/month-map.js +26 -0
- package/src/constants/patterns.js +1 -0
- package/src/constants/validation-fields-export.js +17 -0
- package/src/constants/validation-fields.js +15 -0
- package/src/mappers/business-details-mapper.js +48 -0
- package/src/mappers/mappers.js +3 -1
- package/src/presenters/business-details-presenter.js +67 -0
- package/src/presenters/presenters.js +12 -1
- package/src/schemas/address-schema.js +61 -0
- package/src/schemas/business/business-email-schema.js +19 -0
- package/src/schemas/business/business-name-schema.js +13 -0
- package/src/schemas/business/business-phone-schema.js +33 -0
- package/src/schemas/business/business-schemas.js +14 -1
- package/src/schemas/business/business-vat-schema.js +11 -0
- package/src/schemas/personal/personal-dob-schema.js +178 -0
- package/src/schemas/personal/personal-email-schema.js +20 -0
- package/src/schemas/personal/personal-name-schema.js +31 -0
- package/src/schemas/personal/personal-phone-schema.js +33 -0
- package/src/schemas/personal/personal-schemas.js +13 -0
- package/src/schemas/schemas.js +3 -1
package/dist/index.cjs
CHANGED
|
@@ -87,11 +87,46 @@ var mapCustomerName = (name = {}) => {
|
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
// src/mappers/business-details-mapper.js
|
|
91
|
+
var asNullable = (value) => value ?? null;
|
|
92
|
+
var mapBusinessInfo = (business) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const info = business.info ?? {};
|
|
95
|
+
return {
|
|
96
|
+
sbi: business.sbi,
|
|
97
|
+
businessName: asNullable(info.name),
|
|
98
|
+
vat: asNullable(info.vat),
|
|
99
|
+
traderNumber: asNullable(info.traderNumber),
|
|
100
|
+
vendorNumber: asNullable(info.vendorNumber),
|
|
101
|
+
legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
|
|
102
|
+
type: asNullable((_b = info.type) == null ? void 0 : _b.type),
|
|
103
|
+
countyParishHoldingNumbers: business.countyParishHoldings ?? []
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var mapBusinessContact = (businessInfo) => {
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
return {
|
|
109
|
+
email: asNullable((_a = businessInfo.email) == null ? void 0 : _a.address),
|
|
110
|
+
landline: asNullable((_b = businessInfo.phone) == null ? void 0 : _b.landline),
|
|
111
|
+
mobile: asNullable((_c = businessInfo.phone) == null ? void 0 : _c.mobile)
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var mapBusinessDetails = (value) => {
|
|
115
|
+
const business = (value == null ? void 0 : value.business) ?? {};
|
|
116
|
+
const businessInfo = business.info ?? {};
|
|
117
|
+
return {
|
|
118
|
+
info: mapBusinessInfo(business),
|
|
119
|
+
address: mapAddress(businessInfo.address),
|
|
120
|
+
contact: mapBusinessContact(businessInfo)
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
90
124
|
// src/mappers/mappers.js
|
|
91
125
|
var mappers = {
|
|
92
126
|
personalBusinessDetails: mapPersonalBusinessDetails,
|
|
93
127
|
address: mapAddress,
|
|
94
|
-
customerName: mapCustomerName
|
|
128
|
+
customerName: mapCustomerName,
|
|
129
|
+
businessDetails: mapBusinessDetails
|
|
95
130
|
};
|
|
96
131
|
|
|
97
132
|
// src/schemas/business/business-sbi-schema.js
|
|
@@ -102,15 +137,129 @@ var businessSbiSchema = import_joi.default.object({
|
|
|
102
137
|
})
|
|
103
138
|
});
|
|
104
139
|
|
|
140
|
+
// src/schemas/address-schema.js
|
|
141
|
+
var import_joi2 = __toESM(require("joi"), 1);
|
|
142
|
+
|
|
143
|
+
// src/constants/validation-fields.js
|
|
144
|
+
var FIRST_NAME_MAX = 100;
|
|
145
|
+
var LAST_NAME_MAX = 100;
|
|
146
|
+
var MIDDLE_NAMES_MAX = 100;
|
|
147
|
+
var BUSINESS_NAME_MAX = 160;
|
|
148
|
+
var EMAIL_MAX = 254;
|
|
149
|
+
var PHONE_NUMBER_MIN = 10;
|
|
150
|
+
var PHONE_NUMBER_MAX = 50;
|
|
151
|
+
var MAX_AGE_YEARS = 120;
|
|
152
|
+
var ADDRESS_LINE_MAX = 100;
|
|
153
|
+
var TOWN_CITY_MAX = 60;
|
|
154
|
+
var COUNTY_MAX = 60;
|
|
155
|
+
var COUNTRY_MAX = 60;
|
|
156
|
+
var POSTCODE_MAX = 8;
|
|
157
|
+
|
|
158
|
+
// src/schemas/address-schema.js
|
|
159
|
+
var addressSchema = import_joi2.default.object({
|
|
160
|
+
address1: import_joi2.default.string().required().max(ADDRESS_LINE_MAX).messages({
|
|
161
|
+
"string.empty": "Enter address line 1, typically the building and street",
|
|
162
|
+
"string.max": `Address line 1 must be ${ADDRESS_LINE_MAX} characters or less`,
|
|
163
|
+
"any.required": "Enter address line 1, typically the building and street"
|
|
164
|
+
}),
|
|
165
|
+
address2: import_joi2.default.string().allow("").max(ADDRESS_LINE_MAX).messages({
|
|
166
|
+
"string.max": `Address line 2 must be ${ADDRESS_LINE_MAX} characters or less`
|
|
167
|
+
}),
|
|
168
|
+
address3: import_joi2.default.string().allow("").max(ADDRESS_LINE_MAX).messages({
|
|
169
|
+
"string.max": `Address line 3 must be ${ADDRESS_LINE_MAX} characters or less`
|
|
170
|
+
}),
|
|
171
|
+
city: import_joi2.default.string().required().max(TOWN_CITY_MAX).messages({
|
|
172
|
+
"string.empty": "Enter town or city",
|
|
173
|
+
"string.max": `Town or city must be ${TOWN_CITY_MAX} characters or less`,
|
|
174
|
+
"any.required": "Enter town or city"
|
|
175
|
+
}),
|
|
176
|
+
county: import_joi2.default.string().allow("").max(COUNTY_MAX).messages({
|
|
177
|
+
"string.max": `County must be ${COUNTY_MAX} characters or less`
|
|
178
|
+
}),
|
|
179
|
+
postcode: import_joi2.default.string().required().max(POSTCODE_MAX).messages({
|
|
180
|
+
"any.required": "Enter a postal code or zip code",
|
|
181
|
+
"string.empty": "Enter a postal code or zip code",
|
|
182
|
+
"string.max": `Postal code or zip code must be ${POSTCODE_MAX} characters or less`
|
|
183
|
+
}),
|
|
184
|
+
country: import_joi2.default.string().required().max(COUNTRY_MAX).messages({
|
|
185
|
+
"string.empty": "Enter a country",
|
|
186
|
+
"string.max": `Country must be ${COUNTRY_MAX} characters or less`,
|
|
187
|
+
"any.required": "Enter a country"
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// src/schemas/business/business-name-schema.js
|
|
192
|
+
var import_joi3 = __toESM(require("joi"), 1);
|
|
193
|
+
var businessNameSchema = import_joi3.default.object({
|
|
194
|
+
businessName: import_joi3.default.string().required().max(BUSINESS_NAME_MAX).messages({
|
|
195
|
+
"string.empty": "Enter business name",
|
|
196
|
+
"string.max": `Business name must be ${BUSINESS_NAME_MAX} characters or less`,
|
|
197
|
+
"any.required": "Enter business name"
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/schemas/business/business-email-schema.js
|
|
202
|
+
var import_joi4 = __toESM(require("joi"), 1);
|
|
203
|
+
var businessEmailSchema = import_joi4.default.object({
|
|
204
|
+
businessEmail: import_joi4.default.string().required().max(EMAIL_MAX).email({
|
|
205
|
+
minDomainSegments: 2,
|
|
206
|
+
tlds: {
|
|
207
|
+
allow: true
|
|
208
|
+
}
|
|
209
|
+
}).messages({
|
|
210
|
+
"string.max": `Business email address must be ${EMAIL_MAX} characters or less`,
|
|
211
|
+
"string.empty": "Enter business email address",
|
|
212
|
+
"string.email": "Enter an email address, like name@example.com"
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// src/schemas/business/business-phone-schema.js
|
|
217
|
+
var import_joi5 = __toESM(require("joi"), 1);
|
|
218
|
+
|
|
219
|
+
// src/constants/patterns.js
|
|
220
|
+
var PHONE_NUMBER_PATTERN = /^\+?[0-9 ()]+$/;
|
|
221
|
+
|
|
222
|
+
// src/schemas/business/business-phone-schema.js
|
|
223
|
+
var businessPhoneSchema = import_joi5.default.object({
|
|
224
|
+
businessTelephone: import_joi5.default.string().empty("").min(PHONE_NUMBER_MIN).max(PHONE_NUMBER_MAX).pattern(PHONE_NUMBER_PATTERN).messages({
|
|
225
|
+
"string.min": `Business telephone number must be ${PHONE_NUMBER_MIN} characters or more`,
|
|
226
|
+
"string.max": `Business telephone number must be ${PHONE_NUMBER_MAX} characters or less`,
|
|
227
|
+
"string.pattern.base": "Business telephone number must only include numbers 0 to 9 and special characters such as spaces, brackets and +"
|
|
228
|
+
}),
|
|
229
|
+
businessMobile: import_joi5.default.string().empty("").min(PHONE_NUMBER_MIN).max(PHONE_NUMBER_MAX).pattern(PHONE_NUMBER_PATTERN).messages({
|
|
230
|
+
"string.min": `Business mobile phone number must be ${PHONE_NUMBER_MIN} characters or more`,
|
|
231
|
+
"string.max": `Business mobile phone number must be ${PHONE_NUMBER_MAX} characters or less`,
|
|
232
|
+
"string.pattern.base": "Business mobile phone number must only include numbers 0 to 9 and special characters such as spaces, brackets and +"
|
|
233
|
+
})
|
|
234
|
+
}).or("businessTelephone", "businessMobile").messages({
|
|
235
|
+
"object.missing": "Enter at least one phone number"
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// src/schemas/business/business-vat-schema.js
|
|
239
|
+
var import_joi6 = __toESM(require("joi"), 1);
|
|
240
|
+
var businessVatSchema = import_joi6.default.object({
|
|
241
|
+
vatNumber: import_joi6.default.string().pattern(/^\d{9}$/).allow("").optional().messages({
|
|
242
|
+
"string.pattern.base": "Enter a VAT registration number, like 123456789"
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
|
|
105
246
|
// src/schemas/business/business-schemas.js
|
|
106
247
|
var businessSchemas = {
|
|
107
|
-
sbi: businessSbiSchema
|
|
248
|
+
sbi: businessSbiSchema,
|
|
249
|
+
address: addressSchema,
|
|
250
|
+
details: {
|
|
251
|
+
name: businessNameSchema,
|
|
252
|
+
address: addressSchema,
|
|
253
|
+
phone: businessPhoneSchema,
|
|
254
|
+
email: businessEmailSchema,
|
|
255
|
+
vat: businessVatSchema
|
|
256
|
+
}
|
|
108
257
|
};
|
|
109
258
|
|
|
110
259
|
// src/schemas/customer/customer-crn-schema.js
|
|
111
|
-
var
|
|
112
|
-
var customerCrnSchema =
|
|
113
|
-
crn:
|
|
260
|
+
var import_joi7 = __toESM(require("joi"), 1);
|
|
261
|
+
var customerCrnSchema = import_joi7.default.object({
|
|
262
|
+
crn: import_joi7.default.string().pattern(/^\d{10}$/).allow("").optional().messages({
|
|
114
263
|
"string.pattern.base": "Enter the full CRN"
|
|
115
264
|
})
|
|
116
265
|
});
|
|
@@ -120,10 +269,216 @@ var customerSchemas = {
|
|
|
120
269
|
crn: customerCrnSchema
|
|
121
270
|
};
|
|
122
271
|
|
|
272
|
+
// src/schemas/personal/personal-name-schema.js
|
|
273
|
+
var import_joi8 = __toESM(require("joi"), 1);
|
|
274
|
+
var personalNameSchema = import_joi8.default.object({
|
|
275
|
+
first: import_joi8.default.string().required().max(FIRST_NAME_MAX).messages({
|
|
276
|
+
"string.empty": "Enter first name",
|
|
277
|
+
"string.max": `First name must be ${FIRST_NAME_MAX} characters or less`,
|
|
278
|
+
"any.required": "Enter first name"
|
|
279
|
+
}),
|
|
280
|
+
last: import_joi8.default.string().required().max(LAST_NAME_MAX).messages({
|
|
281
|
+
"string.empty": "Enter last name",
|
|
282
|
+
"string.max": `Last name must be ${LAST_NAME_MAX} characters or less`,
|
|
283
|
+
"any.required": "Enter last name"
|
|
284
|
+
}),
|
|
285
|
+
middle: import_joi8.default.string().allow("").max(MIDDLE_NAMES_MAX).messages({
|
|
286
|
+
"string.max": `Middle names must be ${MIDDLE_NAMES_MAX} characters or less`
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// src/schemas/personal/personal-dob-schema.js
|
|
291
|
+
var import_joi9 = __toESM(require("joi"), 1);
|
|
292
|
+
|
|
293
|
+
// src/constants/month-map.js
|
|
294
|
+
var MONTH_MAP = {
|
|
295
|
+
january: 1,
|
|
296
|
+
jan: 1,
|
|
297
|
+
february: 2,
|
|
298
|
+
feb: 2,
|
|
299
|
+
march: 3,
|
|
300
|
+
mar: 3,
|
|
301
|
+
april: 4,
|
|
302
|
+
apr: 4,
|
|
303
|
+
may: 5,
|
|
304
|
+
june: 6,
|
|
305
|
+
jun: 6,
|
|
306
|
+
july: 7,
|
|
307
|
+
jul: 7,
|
|
308
|
+
august: 8,
|
|
309
|
+
aug: 8,
|
|
310
|
+
september: 9,
|
|
311
|
+
sep: 9,
|
|
312
|
+
sept: 9,
|
|
313
|
+
october: 10,
|
|
314
|
+
oct: 10,
|
|
315
|
+
november: 11,
|
|
316
|
+
nov: 11,
|
|
317
|
+
december: 12,
|
|
318
|
+
dec: 12
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/schemas/personal/personal-dob-schema.js
|
|
322
|
+
var personalDobSchema = import_joi9.default.object({
|
|
323
|
+
day: import_joi9.default.string().allow(""),
|
|
324
|
+
month: import_joi9.default.string().allow(""),
|
|
325
|
+
year: import_joi9.default.string().allow("")
|
|
326
|
+
}).custom((value, helpers) => {
|
|
327
|
+
const { day, month, year } = value;
|
|
328
|
+
const missingFieldsError = checkMissingFields(day, month, year, helpers);
|
|
329
|
+
if (missingFieldsError) {
|
|
330
|
+
return missingFieldsError;
|
|
331
|
+
}
|
|
332
|
+
if (year && year.length !== 4) {
|
|
333
|
+
return makeError(helpers, "dob.yearLength", ["year"]);
|
|
334
|
+
}
|
|
335
|
+
const monthValue = getMonthNumber(month, helpers);
|
|
336
|
+
if (monthValue.isJoiError) {
|
|
337
|
+
return monthValue;
|
|
338
|
+
}
|
|
339
|
+
const fullDate = getFullDate(day, monthValue, year, helpers);
|
|
340
|
+
if (fullDate.isJoiError) {
|
|
341
|
+
return fullDate;
|
|
342
|
+
}
|
|
343
|
+
if (fullDate > /* @__PURE__ */ new Date()) {
|
|
344
|
+
return makeError(helpers, "dob.future", ["day", "month", "year"]);
|
|
345
|
+
}
|
|
346
|
+
const tooOldError = checkNotTooOld(fullDate, helpers);
|
|
347
|
+
if (tooOldError) {
|
|
348
|
+
return tooOldError;
|
|
349
|
+
}
|
|
350
|
+
return value;
|
|
351
|
+
}).messages({
|
|
352
|
+
"dob.missingAll": "Enter your date of birth",
|
|
353
|
+
"dob.missingDay": "Date of birth must include a day",
|
|
354
|
+
"dob.missingMonth": "Date of birth must include a month",
|
|
355
|
+
"dob.missingYear": "Date of birth must include a year",
|
|
356
|
+
"dob.missingDayMonth": "Date of birth must include a day and month",
|
|
357
|
+
"dob.missingDayYear": "Date of birth must include a day and year",
|
|
358
|
+
"dob.missingMonthYear": "Date of birth must include a month and year",
|
|
359
|
+
"dob.yearLength": "Enter a year with 4 numbers, like 1975",
|
|
360
|
+
"dob.invalid": "Date of birth must be a real date",
|
|
361
|
+
"dob.future": "Date of birth must be in the past",
|
|
362
|
+
"dob.tooOld": "Date of birth must be on or after {{#oldest}}"
|
|
363
|
+
});
|
|
364
|
+
var checkNotTooOld = (fullDate, helpers) => {
|
|
365
|
+
const oldestDateAllowed = getOldestAllowedDate();
|
|
366
|
+
if (fullDate < oldestDateAllowed) {
|
|
367
|
+
const oldestDateString = oldestDateAllowed.toLocaleDateString("en-GB", {
|
|
368
|
+
day: "numeric",
|
|
369
|
+
month: "long",
|
|
370
|
+
year: "numeric"
|
|
371
|
+
});
|
|
372
|
+
const error = helpers.error("dob.tooOld", { oldest: oldestDateString });
|
|
373
|
+
error.path = ["day", "month", "year"];
|
|
374
|
+
return error;
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
};
|
|
378
|
+
var getOldestAllowedDate = () => {
|
|
379
|
+
const date = /* @__PURE__ */ new Date();
|
|
380
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
381
|
+
date.setUTCFullYear(date.getUTCFullYear() - MAX_AGE_YEARS);
|
|
382
|
+
return date;
|
|
383
|
+
};
|
|
384
|
+
var getFullDate = (day, monthValue, year, helpers) => {
|
|
385
|
+
const dayValue = Number.parseInt(day, 10);
|
|
386
|
+
const yearValue = Number.parseInt(year, 10);
|
|
387
|
+
const date = new Date(Date.UTC(yearValue, monthValue - 1, dayValue));
|
|
388
|
+
if (date.getUTCFullYear() !== yearValue || date.getUTCMonth() + 1 !== monthValue || date.getUTCDate() !== dayValue) {
|
|
389
|
+
return makeError(helpers, "dob.invalid", ["day", "month", "year"]);
|
|
390
|
+
}
|
|
391
|
+
return date;
|
|
392
|
+
};
|
|
393
|
+
var getMonthNumber = (month, helpers) => {
|
|
394
|
+
if (Number.isNaN(Number(month))) {
|
|
395
|
+
const lower = month.toLowerCase();
|
|
396
|
+
const mapped = MONTH_MAP[lower];
|
|
397
|
+
if (!mapped) {
|
|
398
|
+
return makeError(helpers, "dob.invalid", ["month"]);
|
|
399
|
+
}
|
|
400
|
+
return mapped;
|
|
401
|
+
}
|
|
402
|
+
return Number.parseInt(month, 10);
|
|
403
|
+
};
|
|
404
|
+
var checkMissingFields = (day, month, year, helpers) => {
|
|
405
|
+
if (!day && !month && !year) {
|
|
406
|
+
return makeError(helpers, "dob.missingAll", ["day", "month", "year"]);
|
|
407
|
+
}
|
|
408
|
+
if (!day && month && year) {
|
|
409
|
+
return makeError(helpers, "dob.missingDay", ["day"]);
|
|
410
|
+
}
|
|
411
|
+
if (day && !month && year) {
|
|
412
|
+
return makeError(helpers, "dob.missingMonth", ["month"]);
|
|
413
|
+
}
|
|
414
|
+
if (day && month && !year) {
|
|
415
|
+
return makeError(helpers, "dob.missingYear", ["year"]);
|
|
416
|
+
}
|
|
417
|
+
if (!day && !month && year) {
|
|
418
|
+
return makeError(helpers, "dob.missingDayMonth", ["day", "month"]);
|
|
419
|
+
}
|
|
420
|
+
if (!day && month && !year) {
|
|
421
|
+
return makeError(helpers, "dob.missingDayYear", ["day", "year"]);
|
|
422
|
+
}
|
|
423
|
+
if (day && !month && !year) {
|
|
424
|
+
return makeError(helpers, "dob.missingMonthYear", ["month", "year"]);
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
};
|
|
428
|
+
var makeError = (helpers, code, fields) => {
|
|
429
|
+
const error = helpers.error(code);
|
|
430
|
+
error.path = fields;
|
|
431
|
+
error.isJoiError = true;
|
|
432
|
+
return error;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// src/schemas/personal/personal-email-schema.js
|
|
436
|
+
var import_joi10 = __toESM(require("joi"), 1);
|
|
437
|
+
var personalEmailSchema = import_joi10.default.object({
|
|
438
|
+
personalEmail: import_joi10.default.string().required().max(EMAIL_MAX).email({
|
|
439
|
+
minDomainSegments: 2,
|
|
440
|
+
tlds: {
|
|
441
|
+
allow: true,
|
|
442
|
+
min: 2
|
|
443
|
+
}
|
|
444
|
+
}).messages({
|
|
445
|
+
"string.max": `Email address must be ${EMAIL_MAX} characters or less`,
|
|
446
|
+
"string.empty": "Enter a personal email address",
|
|
447
|
+
"string.email": "Enter an email address, like name@example.com"
|
|
448
|
+
})
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// src/schemas/personal/personal-phone-schema.js
|
|
452
|
+
var import_joi11 = __toESM(require("joi"), 1);
|
|
453
|
+
var personalPhoneSchema = import_joi11.default.object({
|
|
454
|
+
personalTelephone: import_joi11.default.string().empty("").min(PHONE_NUMBER_MIN).max(PHONE_NUMBER_MAX).pattern(PHONE_NUMBER_PATTERN).messages({
|
|
455
|
+
"string.min": `Personal telephone number must be ${PHONE_NUMBER_MIN} characters or more`,
|
|
456
|
+
"string.max": `Personal telephone number must be ${PHONE_NUMBER_MAX} characters or less`,
|
|
457
|
+
"string.pattern.base": "Personal telephone number must only include numbers 0 to 9 and special characters such as spaces, brackets and +"
|
|
458
|
+
}),
|
|
459
|
+
personalMobile: import_joi11.default.string().empty("").min(PHONE_NUMBER_MIN).max(PHONE_NUMBER_MAX).pattern(PHONE_NUMBER_PATTERN).messages({
|
|
460
|
+
"string.min": `Personal mobile phone number must be ${PHONE_NUMBER_MIN} characters or more`,
|
|
461
|
+
"string.max": `Personal mobile phone number must be ${PHONE_NUMBER_MAX} characters or less`,
|
|
462
|
+
"string.pattern.base": "Personal mobile phone number must only include numbers 0 to 9 and special characters such as spaces, brackets and +"
|
|
463
|
+
})
|
|
464
|
+
}).or("personalTelephone", "personalMobile").messages({
|
|
465
|
+
"object.missing": "Enter at least one phone number"
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// src/schemas/personal/personal-schemas.js
|
|
469
|
+
var personalSchemas = {
|
|
470
|
+
name: personalNameSchema,
|
|
471
|
+
dob: personalDobSchema,
|
|
472
|
+
address: addressSchema,
|
|
473
|
+
phone: personalPhoneSchema,
|
|
474
|
+
email: personalEmailSchema
|
|
475
|
+
};
|
|
476
|
+
|
|
123
477
|
// src/schemas/schemas.js
|
|
124
478
|
var schemas = {
|
|
125
479
|
business: businessSchemas,
|
|
126
|
-
customer: customerSchemas
|
|
480
|
+
customer: customerSchemas,
|
|
481
|
+
personal: personalSchemas
|
|
127
482
|
};
|
|
128
483
|
|
|
129
484
|
// src/utils/format-validation-errors.js
|
|
@@ -295,6 +650,24 @@ var sortErrorsBySectionOrder = (errors, orderedSectionsToFix, SECTION_FIELD_ORDE
|
|
|
295
650
|
return sortedErrors;
|
|
296
651
|
};
|
|
297
652
|
|
|
653
|
+
// src/presenters/business-details-presenter.js
|
|
654
|
+
var getActionText = (value) => {
|
|
655
|
+
return value ? "Change" : "Add";
|
|
656
|
+
};
|
|
657
|
+
var formatCph = (countyParishHoldings) => {
|
|
658
|
+
return (countyParishHoldings || []).filter((cph) => cph == null ? void 0 : cph.cphNumber).map((cph) => cph.cphNumber);
|
|
659
|
+
};
|
|
660
|
+
var formatCphText = (count) => {
|
|
661
|
+
return `County Parish Holding (CPH) number${count !== 1 ? "s" : ""}`;
|
|
662
|
+
};
|
|
663
|
+
var formatBusinessAddress = (businessAddress) => {
|
|
664
|
+
var _a, _b;
|
|
665
|
+
if (((_a = businessAddress == null ? void 0 : businessAddress.lookup) == null ? void 0 : _a.uprn) || ((_b = businessAddress == null ? void 0 : businessAddress.manual) == null ? void 0 : _b.line1)) {
|
|
666
|
+
return formatDisplayAddress(businessAddress);
|
|
667
|
+
}
|
|
668
|
+
return [];
|
|
669
|
+
};
|
|
670
|
+
|
|
298
671
|
// src/presenters/presenters.js
|
|
299
672
|
var presenters = {
|
|
300
673
|
formatBackLink,
|
|
@@ -303,7 +676,11 @@ var presenters = {
|
|
|
303
676
|
formatOriginalAddress,
|
|
304
677
|
formatChangedAddress,
|
|
305
678
|
formatDisplayAddresses,
|
|
306
|
-
sortErrorsBySectionOrder
|
|
679
|
+
sortErrorsBySectionOrder,
|
|
680
|
+
getActionText,
|
|
681
|
+
formatCph,
|
|
682
|
+
formatCphText,
|
|
683
|
+
formatBusinessAddress
|
|
307
684
|
};
|
|
308
685
|
// Annotate the CommonJS export names for ESM import in node:
|
|
309
686
|
0 && (module.exports = {
|