@defra-fish/business-rules-lib 1.49.0-rc.7 → 1.49.0-rc.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/business-rules-lib",
3
- "version": "1.49.0-rc.7",
3
+ "version": "1.49.0-rc.9",
4
4
  "description": "Shared business rules for the rod licensing digital services",
5
5
  "type": "module",
6
6
  "engines": {
@@ -37,5 +37,5 @@
37
37
  "moment": "^2.29.1",
38
38
  "uuid": "^8.3.2"
39
39
  },
40
- "gitHead": "a933cacf4f8f557e16ff0d0ee9d8b001723e292c"
40
+ "gitHead": "1e15ad727b21fcf5bae53fbc6a7f06059a42289d"
41
41
  }
@@ -145,7 +145,7 @@ describe('contact validators', () => {
145
145
  'ᴹᶦᶜʰᵃᵉˡ',
146
146
  '𖢑𖥣𖥐𖦙𖧥𖠢ꛚ',
147
147
  'ℳ𝒾𝒸𝒽𝒶ℯ𝓁',
148
- '𝙼𝚒𝚌𝚑𝚊𝚎𝚕'
148
+ '𝙼𝚒𝚌𝚑𝚊𝚎𝚕 '
149
149
  ])('prohibits a string with non-standard characters: %s', async c => {
150
150
  await expect(contactValidation.createFirstNameValidator(Joi).validateAsync(c)).rejects.toThrow()
151
151
  })
@@ -461,22 +461,6 @@ describe('contact validators', () => {
461
461
  '"value" length must be less than or equal to 100 characters long'
462
462
  )
463
463
  })
464
-
465
- it.each([
466
- 'Bond👏 Street',
467
- '🅑ⓞ🅝ⓓ ⓢⓣⓡⓔⓔⓣ',
468
- 'Bond Street',
469
- 'ᴮᵒⁿᵈ ˢᵗʳᵉᵉᵗ',
470
- 'B̲o̲n̲d̲ ̲S̲t̲r̲e̲e̲t̲',
471
- 'B̸o̸n̸d̸ ̸S̸t̸r̸e̸e̸t̸',
472
- '🅑🅞🅝🅓 🅢🅣🅡🅔🅔🅣',
473
- 'B𝑜𝓷d S𝓉𝓇𝑒𝑒𝓉',
474
- 'もB囗o几n问d 丂S匕t尺r乇eモe匕t',
475
- 'B⃠o⃠n⃠d⃠ S⃠t⃠r⃠e⃠e⃠t⃠',
476
- '𝐁𝐨𝐧𝐝 𝐒𝐭𝐫𝐞𝐞𝐭'
477
- ])('prohibits a string with non-standard characters: %s', async c => {
478
- await expect(contactValidation.createStreetValidator(Joi).validateAsync(c)).rejects.toThrow()
479
- })
480
464
  })
481
465
 
482
466
  describe('localityValidator', () => {
@@ -493,20 +477,6 @@ describe('contact validators', () => {
493
477
  '"value" length must be less than or equal to 100 characters long'
494
478
  )
495
479
  })
496
-
497
- it.each([
498
- 'M̲a̲y̲f̲a̲i̲r̲',
499
- 'M̸a̸y̸f̸a̸i̸r̸',
500
- 'Mayfair',
501
- 'ᴹᵃʸᶠᵃⁱʳ',
502
- '🅜🅐🅨🅕🅐🅘🅡',
503
- '🅜ⓐ🅨ⓕⓐⓘⓡ',
504
- '爪M丹aリy乍f丹a工i尺r',
505
- 'M⃠a⃠y⃠f⃠a⃠i⃠r⃠',
506
- '𝐌𝐚𝐲𝐟𝐚𝐢𝐫'
507
- ])('prohibits a string with non-standard characters: %s', async c => {
508
- await expect(contactValidation.createLocalityValidator(Joi).validateAsync(c)).rejects.toThrow()
509
- })
510
480
  })
511
481
 
512
482
  describe('townValidator', () => {
@@ -79,9 +79,9 @@ const createDateStringValidator = joi =>
79
79
  })
80
80
 
81
81
  const allowedUnicodeBlocks = '\\u0000-\\u024F'
82
- const forbiddenCharsRegex = new RegExp(`[^${allowedUnicodeBlocks}\\s'’()-]`, 'gu')
83
- const forbiddenEmailRegex = new RegExp(`[^A-Za-z0-9\\s'’@._${allowedUnicodeBlocks}]`, 'gu')
84
- const forbiddenCharsNumbersRegex = new RegExp(`[^A-Za-z0-9\\s${allowedUnicodeBlocks}]`, 'gu')
82
+ const forbiddenCharsRegex = new RegExp(`[^${allowedUnicodeBlocks}\\s'’()-]`, 'u')
83
+ const forbiddenEmailRegex = new RegExp(`[^A-Za-z0-9\\s'’@._${allowedUnicodeBlocks}]`, 'u')
84
+ const forbiddenCharsNumbersRegex = new RegExp(`[^A-Za-z0-9\\s${allowedUnicodeBlocks}]`, 'u')
85
85
  const forbiddenMobileRegex = /[^+()0-9\-.\s]+/g
86
86
 
87
87
  /**
@@ -136,15 +136,7 @@ export const createPremisesValidator = joi =>
136
136
  * @param {Joi.Root} joi the joi validator used by the consuming project
137
137
  * @returns {Joi.StringSchema}
138
138
  */
139
- export const createStreetValidator = joi =>
140
- checkCopyPasteValidator(joi, forbiddenCharsRegex)
141
- .string()
142
- .allowable()
143
- .trim()
144
- .max(100)
145
- .external(toTitleCase())
146
- .empty('')
147
- .example('Example Street')
139
+ export const createStreetValidator = joi => joi.string().trim().max(100).external(toTitleCase()).empty('').example('Example Street')
148
140
 
149
141
  /**
150
142
  * Create a validator to check a contact's address locality
@@ -152,15 +144,7 @@ export const createStreetValidator = joi =>
152
144
  * @param {Joi.Root} joi the joi validator used by the consuming project
153
145
  * @returns {Joi.StringSchema}
154
146
  */
155
- export const createLocalityValidator = joi =>
156
- checkCopyPasteValidator(joi, forbiddenCharsRegex)
157
- .string()
158
- .allowable()
159
- .trim()
160
- .max(100)
161
- .external(toTitleCase())
162
- .empty('')
163
- .example('Near Sample')
147
+ export const createLocalityValidator = joi => joi.string().trim().max(100).external(toTitleCase()).empty('').example('Near Sample')
164
148
 
165
149
  /**
166
150
  * Create a validator to check a contact's address town