@defra/fcp-sfd-frontend-engine 0.27.0 → 0.29.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 CHANGED
@@ -337,6 +337,7 @@ var asNullable = (value) => value ?? null;
337
337
  var mapBusinessInfo = (business) => {
338
338
  var _a, _b, _c;
339
339
  const info = business.info ?? {};
340
+ const registrationNumbers = info.registrationNumbers ?? {};
340
341
  return {
341
342
  sbi: business.sbi,
342
343
  businessName: asNullable(info.name),
@@ -345,6 +346,10 @@ var mapBusinessInfo = (business) => {
345
346
  vendorNumber: asNullable(info.vendorNumber),
346
347
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
347
348
  legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
349
+ registrationNumbers: {
350
+ companiesHouse: asNullable(registrationNumbers.companiesHouse),
351
+ charityCommission: asNullable(registrationNumbers.charityCommission)
352
+ },
348
353
  type: asNullable((_c = info.type) == null ? void 0 : _c.type),
349
354
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
350
355
  };
@@ -476,7 +481,7 @@ var businessPhoneSchema = Joi.object({
476
481
 
477
482
  // src/schemas/business/business-vat-schema.js
478
483
  var businessVatSchema = Joi.object({
479
- vatNumber: Joi.string().pattern(/^\d{9}$/).allow("").optional().messages({
484
+ vatNumber: Joi.string().trim().pattern(/^\d{9}$/).allow("").optional().messages({
480
485
  "string.pattern.base": "Enter a VAT registration number, like 123456789",
481
486
  "string.noControlChars": "VAT registration number must not contain invalid characters"
482
487
  })
@@ -484,7 +489,7 @@ var businessVatSchema = Joi.object({
484
489
 
485
490
  // src/schemas/business/business-vat-change-schema.js
486
491
  var businessVatChangeSchema = Joi.object({
487
- vatNumber: Joi.string().pattern(/^\d{9}$/).required().messages({
492
+ vatNumber: Joi.string().trim().pattern(/^\d{9}$/).required().messages({
488
493
  "string.pattern.base": "Enter a VAT registration number, like 123456789",
489
494
  "string.empty": "Enter a VAT registration number",
490
495
  "any.required": "Enter a VAT registration number",
package/dist/index.js CHANGED
@@ -296,6 +296,7 @@ var asNullable = (value) => value ?? null;
296
296
  var mapBusinessInfo = (business) => {
297
297
  var _a, _b, _c;
298
298
  const info = business.info ?? {};
299
+ const registrationNumbers = info.registrationNumbers ?? {};
299
300
  return {
300
301
  sbi: business.sbi,
301
302
  businessName: asNullable(info.name),
@@ -304,6 +305,10 @@ var mapBusinessInfo = (business) => {
304
305
  vendorNumber: asNullable(info.vendorNumber),
305
306
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
306
307
  legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
308
+ registrationNumbers: {
309
+ companiesHouse: asNullable(registrationNumbers.companiesHouse),
310
+ charityCommission: asNullable(registrationNumbers.charityCommission)
311
+ },
307
312
  type: asNullable((_c = info.type) == null ? void 0 : _c.type),
308
313
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
309
314
  };
@@ -435,7 +440,7 @@ var businessPhoneSchema = Joi.object({
435
440
 
436
441
  // src/schemas/business/business-vat-schema.js
437
442
  var businessVatSchema = Joi.object({
438
- vatNumber: Joi.string().pattern(/^\d{9}$/).allow("").optional().messages({
443
+ vatNumber: Joi.string().trim().pattern(/^\d{9}$/).allow("").optional().messages({
439
444
  "string.pattern.base": "Enter a VAT registration number, like 123456789",
440
445
  "string.noControlChars": "VAT registration number must not contain invalid characters"
441
446
  })
@@ -443,7 +448,7 @@ var businessVatSchema = Joi.object({
443
448
 
444
449
  // src/schemas/business/business-vat-change-schema.js
445
450
  var businessVatChangeSchema = Joi.object({
446
- vatNumber: Joi.string().pattern(/^\d{9}$/).required().messages({
451
+ vatNumber: Joi.string().trim().pattern(/^\d{9}$/).required().messages({
447
452
  "string.pattern.base": "Enter a VAT registration number, like 123456789",
448
453
  "string.empty": "Enter a VAT registration number",
449
454
  "any.required": "Enter a VAT registration number",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/fcp-sfd-frontend-engine",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Shared frontend engine used by both the internal and external frontend applications.",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
@@ -15,6 +15,7 @@ const asNullable = (value) => value ?? null
15
15
 
16
16
  const mapBusinessInfo = (business) => {
17
17
  const info = business.info ?? {}
18
+ const registrationNumbers = info.registrationNumbers ?? {}
18
19
 
19
20
  return {
20
21
  sbi: business.sbi,
@@ -24,6 +25,10 @@ const mapBusinessInfo = (business) => {
24
25
  vendorNumber: asNullable(info.vendorNumber),
25
26
  legalStatus: asNullable(info.legalStatus?.type),
26
27
  legalStatusCode: asNullable(info.legalStatus?.code),
28
+ registrationNumbers: {
29
+ companiesHouse: asNullable(registrationNumbers.companiesHouse),
30
+ charityCommission: asNullable(registrationNumbers.charityCommission)
31
+ },
27
32
  type: asNullable(info.type?.type),
28
33
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
29
34
  }
@@ -2,6 +2,7 @@ import { Joi } from '../../utils/joi.js'
2
2
 
3
3
  export const businessVatChangeSchema = Joi.object({
4
4
  vatNumber: Joi.string()
5
+ .trim()
5
6
  .pattern(/^\d{9}$/)
6
7
  .required()
7
8
  .messages({
@@ -2,6 +2,7 @@ import { Joi } from '../../utils/joi.js'
2
2
 
3
3
  export const businessVatSchema = Joi.object({
4
4
  vatNumber: Joi.string()
5
+ .trim()
5
6
  .pattern(/^\d{9}$/)
6
7
  .allow('')
7
8
  .optional()