@defra/fcp-sfd-frontend-engine 0.9.0 → 0.9.1

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
@@ -266,6 +266,16 @@ var businessVatSchema = Joi.object({
266
266
  })
267
267
  });
268
268
 
269
+ // src/schemas/business/business-vat-change-schema.js
270
+ var businessVatChangeSchema = Joi.object({
271
+ vatNumber: Joi.string().pattern(/^\d{9}$/).required().messages({
272
+ "string.pattern.base": "Enter a VAT registration number, like 123456789",
273
+ "string.empty": "Enter a VAT registration number",
274
+ "any.required": "Enter a VAT registration number",
275
+ "string.noControlChars": "VAT registration number must not contain invalid characters"
276
+ })
277
+ });
278
+
269
279
  // src/schemas/business/business-vat-remove-schema.js
270
280
  var businessVatRemoveSchema = Joi.object({
271
281
  confirmRemove: Joi.string().valid("yes", "no").required().messages({
@@ -284,7 +294,10 @@ var businessSchemas = {
284
294
  email: businessEmailSchema,
285
295
  vat: businessVatSchema
286
296
  },
287
- vatRemove: businessVatRemoveSchema
297
+ vat: {
298
+ change: businessVatChangeSchema,
299
+ remove: businessVatRemoveSchema
300
+ }
288
301
  };
289
302
 
290
303
  // src/schemas/customer/customer-crn-schema.js
package/dist/index.js CHANGED
@@ -227,6 +227,16 @@ var businessVatSchema = Joi.object({
227
227
  })
228
228
  });
229
229
 
230
+ // src/schemas/business/business-vat-change-schema.js
231
+ var businessVatChangeSchema = Joi.object({
232
+ vatNumber: Joi.string().pattern(/^\d{9}$/).required().messages({
233
+ "string.pattern.base": "Enter a VAT registration number, like 123456789",
234
+ "string.empty": "Enter a VAT registration number",
235
+ "any.required": "Enter a VAT registration number",
236
+ "string.noControlChars": "VAT registration number must not contain invalid characters"
237
+ })
238
+ });
239
+
230
240
  // src/schemas/business/business-vat-remove-schema.js
231
241
  var businessVatRemoveSchema = Joi.object({
232
242
  confirmRemove: Joi.string().valid("yes", "no").required().messages({
@@ -245,7 +255,10 @@ var businessSchemas = {
245
255
  email: businessEmailSchema,
246
256
  vat: businessVatSchema
247
257
  },
248
- vatRemove: businessVatRemoveSchema
258
+ vat: {
259
+ change: businessVatChangeSchema,
260
+ remove: businessVatRemoveSchema
261
+ }
249
262
  };
250
263
 
251
264
  // src/schemas/customer/customer-crn-schema.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/fcp-sfd-frontend-engine",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Shared frontend engine used by both the internal and external frontend applications.",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
@@ -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 { businessVatChangeSchema } from './business-vat-change-schema.js'
7
8
  import { businessVatRemoveSchema } from './business-vat-remove-schema.js'
8
9
 
9
10
  /**
@@ -11,6 +12,15 @@ import { businessVatRemoveSchema } from './business-vat-remove-schema.js'
11
12
  * This is due to the interrupter journey. The journey required the business details to be validated in a single step,
12
13
  * these include name, address, phone, email and vat. The `details` property is used to group these schemas together.
13
14
  * The `sbi` property is separate as it is validated in a different step of the journey.
15
+ *
16
+ * The `vat` property groups the schemas for the standalone VAT action pages:
17
+ * - `vat.change` validates the dedicated VAT change page where a VAT registration number is mandatory
18
+ * (9 digits, `.required()`), so it is deliberately separate from `details.vat`.
19
+ * - `vat.remove` validates the VAT removal confirmation page (yes/no).
20
+ *
21
+ * Note `details.vat` and `vat.change` are two distinct validation contexts for the same field: within the
22
+ * interrupter `details` set VAT is optional and an empty string is allowed, whereas on the dedicated change
23
+ * page a valid VAT number must be entered (removal is handled by its own journey).
14
24
  */
15
25
  export const businessSchemas = {
16
26
  sbi: businessSbiSchema,
@@ -21,5 +31,8 @@ export const businessSchemas = {
21
31
  email: businessEmailSchema,
22
32
  vat: businessVatSchema
23
33
  },
24
- vatRemove: businessVatRemoveSchema
34
+ vat: {
35
+ change: businessVatChangeSchema,
36
+ remove: businessVatRemoveSchema
37
+ }
25
38
  }
@@ -0,0 +1,13 @@
1
+ import { Joi } from '../../utils/joi.js'
2
+
3
+ export const businessVatChangeSchema = Joi.object({
4
+ vatNumber: Joi.string()
5
+ .pattern(/^\d{9}$/)
6
+ .required()
7
+ .messages({
8
+ 'string.pattern.base': 'Enter a VAT registration number, like 123456789',
9
+ 'string.empty': 'Enter a VAT registration number',
10
+ 'any.required': 'Enter a VAT registration number',
11
+ 'string.noControlChars': 'VAT registration number must not contain invalid characters'
12
+ })
13
+ })