hof 19.11.3 → 19.11.7

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.
@@ -92,14 +92,16 @@ module.exports = Validators = {
92
92
  * Validates international phone numbers (fixed and mobile) including UK.
93
93
  * Non-GB phone numbers will require country code to validate.
94
94
  */
95
- internationalPhoneNumber(value) {
96
- const phoneNumber = libPhoneNumber.parsePhoneNumberFromString(value, 'GB') || '';
97
- return value === '' || (phoneNumber && phoneNumber.isValid());
95
+ internationalPhoneNumber(value, code) {
96
+ const countryCode = code || 'GB';
97
+ const phoneNumber = libPhoneNumber.parsePhoneNumberFromString(value, countryCode) || '';
98
+ const isValidComparedToGivenCountry = code ? phoneNumber.country === countryCode : true;
99
+ return value === '' || (phoneNumber && phoneNumber.isValid() && isValidComparedToGivenCountry);
98
100
  },
99
101
 
100
102
  ukPhoneNumber(value) {
101
- const phoneNumber = libPhoneNumber.parsePhoneNumberFromString(value, 'GB');
102
- return phoneNumber && phoneNumber.isValid() && phoneNumber.country === 'GB';
103
+ const phoneNumber = libPhoneNumber.parsePhoneNumberFromString(value, 'GB') || '';
104
+ return value === '' || (phoneNumber && phoneNumber.isValid() && phoneNumber.country === 'GB');
103
105
  },
104
106
 
105
107
  ukmobilephone(value) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hof",
3
3
  "description": "A bootstrap for HOF projects",
4
- "version": "19.11.3",
4
+ "version": "19.11.7",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",
@@ -62,7 +62,7 @@
62
62
  "i18n-future": "^2.0.0",
63
63
  "i18n-lookup": "^0.1.0",
64
64
  "is-pdf": "^1.0.0",
65
- "libphonenumber-js": "^1.9.22",
65
+ "libphonenumber-js": "^1.9.24",
66
66
  "lodash": "^4.17.21",
67
67
  "markdown-it": "^12.2.0",
68
68
  "minimatch": "^3.0.3",