@defra/fcp-sfd-frontend-engine 0.8.5 → 0.9.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 +60 -2
- package/dist/index.js +60 -2
- package/package.json +1 -1
- package/src/schemas/business/business-schemas.js +3 -1
- package/src/schemas/business/business-vat-remove-schema.js +11 -0
- package/src/schemas/os-places/address-lookup-schema.js +21 -0
- package/src/schemas/os-places/addresses-schema.js +14 -0
- package/src/schemas/os-places/os-places-schemas.js +9 -0
- package/src/schemas/os-places/uk-postcode-schema.js +17 -0
- package/src/schemas/schemas.js +3 -1
package/dist/index.cjs
CHANGED
|
@@ -266,6 +266,14 @@ var businessVatSchema = Joi.object({
|
|
|
266
266
|
})
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
+
// src/schemas/business/business-vat-remove-schema.js
|
|
270
|
+
var businessVatRemoveSchema = Joi.object({
|
|
271
|
+
confirmRemove: Joi.string().valid("yes", "no").required().messages({
|
|
272
|
+
"any.required": "Select yes if you want to remove your VAT registration number",
|
|
273
|
+
"any.only": "Select yes if you want to remove your VAT registration number"
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
|
|
269
277
|
// src/schemas/business/business-schemas.js
|
|
270
278
|
var businessSchemas = {
|
|
271
279
|
sbi: businessSbiSchema,
|
|
@@ -275,7 +283,8 @@ var businessSchemas = {
|
|
|
275
283
|
phone: businessPhoneSchema,
|
|
276
284
|
email: businessEmailSchema,
|
|
277
285
|
vat: businessVatSchema
|
|
278
|
-
}
|
|
286
|
+
},
|
|
287
|
+
vatRemove: businessVatRemoveSchema
|
|
279
288
|
};
|
|
280
289
|
|
|
281
290
|
// src/schemas/customer/customer-crn-schema.js
|
|
@@ -503,11 +512,60 @@ var personalSchemas = {
|
|
|
503
512
|
email: personalEmailSchema
|
|
504
513
|
};
|
|
505
514
|
|
|
515
|
+
// src/schemas/os-places/address-lookup-schema.js
|
|
516
|
+
var addressLookupSchema = Joi.object({
|
|
517
|
+
properties: Joi.object({
|
|
518
|
+
UPRN: Joi.string().required(),
|
|
519
|
+
ADDRESS: Joi.string().required(),
|
|
520
|
+
ORGANISATION_NAME: Joi.string().allow(null),
|
|
521
|
+
DEPARTMENT_NAME: Joi.string().allow(null),
|
|
522
|
+
SUB_BUILDING_NAME: Joi.string().allow(null),
|
|
523
|
+
BUILDING_NAME: Joi.string().allow(null),
|
|
524
|
+
BUILDING_NUMBER: Joi.string().allow(null),
|
|
525
|
+
DEPENDENT_THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
526
|
+
THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
527
|
+
DOUBLE_DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
528
|
+
DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
529
|
+
POST_TOWN: Joi.string().required(),
|
|
530
|
+
POSTCODE: Joi.string().required(),
|
|
531
|
+
LOCAL_CUSTODIAN_CODE_DESCRIPTION: Joi.string().allow(null),
|
|
532
|
+
COUNTRY_CODE: Joi.string().required()
|
|
533
|
+
}).unknown(true).required()
|
|
534
|
+
}).unknown(true);
|
|
535
|
+
|
|
536
|
+
// src/schemas/os-places/addresses-schema.js
|
|
537
|
+
var CHOOSE_ADDRESS_ERROR = "Choose an address";
|
|
538
|
+
var addressesSchema = Joi.object({
|
|
539
|
+
addresses: Joi.string().invalid("display").required().messages({
|
|
540
|
+
"any.required": CHOOSE_ADDRESS_ERROR,
|
|
541
|
+
"string.empty": CHOOSE_ADDRESS_ERROR,
|
|
542
|
+
"any.invalid": CHOOSE_ADDRESS_ERROR
|
|
543
|
+
})
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// src/schemas/os-places/uk-postcode-schema.js
|
|
547
|
+
var ukPostcodeSchema = Joi.object({
|
|
548
|
+
postcode: Joi.string().trim().required().uppercase().max(POSTCODE_MAX).pattern(/^([A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}|GIR ?0A{2})$/).messages({
|
|
549
|
+
"any.required": "Enter a postcode",
|
|
550
|
+
"string.empty": "Enter a postcode",
|
|
551
|
+
"string.max": `Postal code must be ${POSTCODE_MAX} characters or less`,
|
|
552
|
+
"string.pattern.base": "Enter a full UK postcode, like AA3 1AB"
|
|
553
|
+
})
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
// src/schemas/os-places/os-places-schemas.js
|
|
557
|
+
var osPlacesSchemas = {
|
|
558
|
+
addressLookup: addressLookupSchema,
|
|
559
|
+
addresses: addressesSchema,
|
|
560
|
+
ukPostcode: ukPostcodeSchema
|
|
561
|
+
};
|
|
562
|
+
|
|
506
563
|
// src/schemas/schemas.js
|
|
507
564
|
var schemas = {
|
|
508
565
|
business: businessSchemas,
|
|
509
566
|
customer: customerSchemas,
|
|
510
|
-
personal: personalSchemas
|
|
567
|
+
personal: personalSchemas,
|
|
568
|
+
osPlaces: osPlacesSchemas
|
|
511
569
|
};
|
|
512
570
|
|
|
513
571
|
// src/utils/format-validation-errors.js
|
package/dist/index.js
CHANGED
|
@@ -227,6 +227,14 @@ var businessVatSchema = Joi.object({
|
|
|
227
227
|
})
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
+
// src/schemas/business/business-vat-remove-schema.js
|
|
231
|
+
var businessVatRemoveSchema = Joi.object({
|
|
232
|
+
confirmRemove: Joi.string().valid("yes", "no").required().messages({
|
|
233
|
+
"any.required": "Select yes if you want to remove your VAT registration number",
|
|
234
|
+
"any.only": "Select yes if you want to remove your VAT registration number"
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
|
|
230
238
|
// src/schemas/business/business-schemas.js
|
|
231
239
|
var businessSchemas = {
|
|
232
240
|
sbi: businessSbiSchema,
|
|
@@ -236,7 +244,8 @@ var businessSchemas = {
|
|
|
236
244
|
phone: businessPhoneSchema,
|
|
237
245
|
email: businessEmailSchema,
|
|
238
246
|
vat: businessVatSchema
|
|
239
|
-
}
|
|
247
|
+
},
|
|
248
|
+
vatRemove: businessVatRemoveSchema
|
|
240
249
|
};
|
|
241
250
|
|
|
242
251
|
// src/schemas/customer/customer-crn-schema.js
|
|
@@ -464,11 +473,60 @@ var personalSchemas = {
|
|
|
464
473
|
email: personalEmailSchema
|
|
465
474
|
};
|
|
466
475
|
|
|
476
|
+
// src/schemas/os-places/address-lookup-schema.js
|
|
477
|
+
var addressLookupSchema = Joi.object({
|
|
478
|
+
properties: Joi.object({
|
|
479
|
+
UPRN: Joi.string().required(),
|
|
480
|
+
ADDRESS: Joi.string().required(),
|
|
481
|
+
ORGANISATION_NAME: Joi.string().allow(null),
|
|
482
|
+
DEPARTMENT_NAME: Joi.string().allow(null),
|
|
483
|
+
SUB_BUILDING_NAME: Joi.string().allow(null),
|
|
484
|
+
BUILDING_NAME: Joi.string().allow(null),
|
|
485
|
+
BUILDING_NUMBER: Joi.string().allow(null),
|
|
486
|
+
DEPENDENT_THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
487
|
+
THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
488
|
+
DOUBLE_DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
489
|
+
DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
490
|
+
POST_TOWN: Joi.string().required(),
|
|
491
|
+
POSTCODE: Joi.string().required(),
|
|
492
|
+
LOCAL_CUSTODIAN_CODE_DESCRIPTION: Joi.string().allow(null),
|
|
493
|
+
COUNTRY_CODE: Joi.string().required()
|
|
494
|
+
}).unknown(true).required()
|
|
495
|
+
}).unknown(true);
|
|
496
|
+
|
|
497
|
+
// src/schemas/os-places/addresses-schema.js
|
|
498
|
+
var CHOOSE_ADDRESS_ERROR = "Choose an address";
|
|
499
|
+
var addressesSchema = Joi.object({
|
|
500
|
+
addresses: Joi.string().invalid("display").required().messages({
|
|
501
|
+
"any.required": CHOOSE_ADDRESS_ERROR,
|
|
502
|
+
"string.empty": CHOOSE_ADDRESS_ERROR,
|
|
503
|
+
"any.invalid": CHOOSE_ADDRESS_ERROR
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// src/schemas/os-places/uk-postcode-schema.js
|
|
508
|
+
var ukPostcodeSchema = Joi.object({
|
|
509
|
+
postcode: Joi.string().trim().required().uppercase().max(POSTCODE_MAX).pattern(/^([A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}|GIR ?0A{2})$/).messages({
|
|
510
|
+
"any.required": "Enter a postcode",
|
|
511
|
+
"string.empty": "Enter a postcode",
|
|
512
|
+
"string.max": `Postal code must be ${POSTCODE_MAX} characters or less`,
|
|
513
|
+
"string.pattern.base": "Enter a full UK postcode, like AA3 1AB"
|
|
514
|
+
})
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
// src/schemas/os-places/os-places-schemas.js
|
|
518
|
+
var osPlacesSchemas = {
|
|
519
|
+
addressLookup: addressLookupSchema,
|
|
520
|
+
addresses: addressesSchema,
|
|
521
|
+
ukPostcode: ukPostcodeSchema
|
|
522
|
+
};
|
|
523
|
+
|
|
467
524
|
// src/schemas/schemas.js
|
|
468
525
|
var schemas = {
|
|
469
526
|
business: businessSchemas,
|
|
470
527
|
customer: customerSchemas,
|
|
471
|
-
personal: personalSchemas
|
|
528
|
+
personal: personalSchemas,
|
|
529
|
+
osPlaces: osPlacesSchemas
|
|
472
530
|
};
|
|
473
531
|
|
|
474
532
|
// src/utils/format-validation-errors.js
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { businessNameSchema } from './business-name-schema.js'
|
|
|
4
4
|
import { businessEmailSchema } from './business-email-schema.js'
|
|
5
5
|
import { businessPhoneSchema } from './business-phone-schema.js'
|
|
6
6
|
import { businessVatSchema } from './business-vat-schema.js'
|
|
7
|
+
import { businessVatRemoveSchema } from './business-vat-remove-schema.js'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The businessSchema object has a nested property of `details`.
|
|
@@ -19,5 +20,6 @@ export const businessSchemas = {
|
|
|
19
20
|
phone: businessPhoneSchema,
|
|
20
21
|
email: businessEmailSchema,
|
|
21
22
|
vat: businessVatSchema
|
|
22
|
-
}
|
|
23
|
+
},
|
|
24
|
+
vatRemove: businessVatRemoveSchema
|
|
23
25
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Joi } from '../../utils/joi.js'
|
|
2
|
+
|
|
3
|
+
export const businessVatRemoveSchema = Joi.object({
|
|
4
|
+
confirmRemove: Joi.string()
|
|
5
|
+
.valid('yes', 'no')
|
|
6
|
+
.required()
|
|
7
|
+
.messages({
|
|
8
|
+
'any.required': 'Select yes if you want to remove your VAT registration number',
|
|
9
|
+
'any.only': 'Select yes if you want to remove your VAT registration number'
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Joi } from '../../utils/joi.js'
|
|
2
|
+
|
|
3
|
+
export const addressLookupSchema = Joi.object({
|
|
4
|
+
properties: Joi.object({
|
|
5
|
+
UPRN: Joi.string().required(),
|
|
6
|
+
ADDRESS: Joi.string().required(),
|
|
7
|
+
ORGANISATION_NAME: Joi.string().allow(null),
|
|
8
|
+
DEPARTMENT_NAME: Joi.string().allow(null),
|
|
9
|
+
SUB_BUILDING_NAME: Joi.string().allow(null),
|
|
10
|
+
BUILDING_NAME: Joi.string().allow(null),
|
|
11
|
+
BUILDING_NUMBER: Joi.string().allow(null),
|
|
12
|
+
DEPENDENT_THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
13
|
+
THOROUGHFARE_NAME: Joi.string().allow(null),
|
|
14
|
+
DOUBLE_DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
15
|
+
DEPENDENT_LOCALITY: Joi.string().allow(null),
|
|
16
|
+
POST_TOWN: Joi.string().required(),
|
|
17
|
+
POSTCODE: Joi.string().required(),
|
|
18
|
+
LOCAL_CUSTODIAN_CODE_DESCRIPTION: Joi.string().allow(null),
|
|
19
|
+
COUNTRY_CODE: Joi.string().required()
|
|
20
|
+
}).unknown(true).required()
|
|
21
|
+
}).unknown(true)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Joi } from '../../utils/joi.js'
|
|
2
|
+
|
|
3
|
+
const CHOOSE_ADDRESS_ERROR = 'Choose an address'
|
|
4
|
+
|
|
5
|
+
export const addressesSchema = Joi.object({
|
|
6
|
+
addresses: Joi.string()
|
|
7
|
+
.invalid('display')
|
|
8
|
+
.required()
|
|
9
|
+
.messages({
|
|
10
|
+
'any.required': CHOOSE_ADDRESS_ERROR,
|
|
11
|
+
'string.empty': CHOOSE_ADDRESS_ERROR,
|
|
12
|
+
'any.invalid': CHOOSE_ADDRESS_ERROR
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { addressLookupSchema } from './address-lookup-schema.js'
|
|
2
|
+
import { addressesSchema } from './addresses-schema.js'
|
|
3
|
+
import { ukPostcodeSchema } from './uk-postcode-schema.js'
|
|
4
|
+
|
|
5
|
+
export const osPlacesSchemas = {
|
|
6
|
+
addressLookup: addressLookupSchema,
|
|
7
|
+
addresses: addressesSchema,
|
|
8
|
+
ukPostcode: ukPostcodeSchema
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Joi } from '../../utils/joi.js'
|
|
2
|
+
import { POSTCODE_MAX } from '../../constants/validation-fields.js'
|
|
3
|
+
|
|
4
|
+
export const ukPostcodeSchema = Joi.object({
|
|
5
|
+
postcode: Joi.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.required()
|
|
8
|
+
.uppercase()
|
|
9
|
+
.max(POSTCODE_MAX)
|
|
10
|
+
.pattern(/^([A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}|GIR ?0A{2})$/)
|
|
11
|
+
.messages({
|
|
12
|
+
'any.required': 'Enter a postcode',
|
|
13
|
+
'string.empty': 'Enter a postcode',
|
|
14
|
+
'string.max': `Postal code must be ${POSTCODE_MAX} characters or less`,
|
|
15
|
+
'string.pattern.base': 'Enter a full UK postcode, like AA3 1AB'
|
|
16
|
+
})
|
|
17
|
+
})
|
package/src/schemas/schemas.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { businessSchemas } from './business/business-schemas.js'
|
|
2
2
|
import { customerSchemas } from './customer/customer-schemas.js'
|
|
3
3
|
import { personalSchemas } from './personal/personal-schemas.js'
|
|
4
|
+
import { osPlacesSchemas } from './os-places/os-places-schemas.js'
|
|
4
5
|
|
|
5
6
|
export const schemas = {
|
|
6
7
|
business: businessSchemas,
|
|
7
8
|
customer: customerSchemas,
|
|
8
|
-
personal: personalSchemas
|
|
9
|
+
personal: personalSchemas,
|
|
10
|
+
osPlaces: osPlacesSchemas
|
|
9
11
|
}
|