@comicrelief/component-library 5.8.3 → 5.8.4

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.
@@ -154,13 +154,13 @@ describe('MarketingPreferencesDSForm component', () => {
154
154
  cy.get('@default')
155
155
  .find('.field-sms span[data-test=error-message] span')
156
156
  .should('exist')
157
- .contains('Please enter a valid mobile number');
157
+ .contains('Please enter a valid UK mobile number');
158
158
 
159
159
  // Phone
160
160
  cy.get('@default')
161
161
  .find('.field-phone span[data-test=error-message] span')
162
162
  .should('exist')
163
- .contains('Please enter a valid phone number');
163
+ .contains('Please enter a valid UK phone number');
164
164
 
165
165
  // Address1
166
166
  cy.get('@default')
@@ -424,7 +424,7 @@ describe('MarketingPreferencesDSForm component', () => {
424
424
  cy.get('@customised')
425
425
  .find('.field-phone span[data-test=error-message] span')
426
426
  .should('exist')
427
- .contains('Please enter a valid phone number');
427
+ .contains('Please enter a valid UK phone number');
428
428
 
429
429
  // Address1
430
430
  cy.get('@customised')
@@ -7,8 +7,6 @@ exports.buildValidationSchema = exports.setInitialValues = void 0;
7
7
 
8
8
  var yup = _interopRequireWildcard(require("yup"));
9
9
 
10
- require("yup-phone");
11
-
12
10
  var _lodash = require("lodash");
13
11
 
14
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -75,6 +73,7 @@ var buildValidationSchema = function buildValidationSchema(overrideOptions) {
75
73
  }; // Override with any custom options supplied
76
74
 
77
75
  var mpValidationOptions = (0, _lodash.merge)(defaultOptions, overrideOptions);
76
+ var phoneRegex = /^(((((\+44)|(0044))\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((((\+44)|(0044))\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((((\+44)|(0044))\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\\#(\d{4}|\d{3}))?$/;
78
77
  var mpValidationSchema = yup.object({
79
78
  mp_email: yup.string().when('mp_permissionEmail', {
80
79
  is: function is(val) {
@@ -86,13 +85,13 @@ var buildValidationSchema = function buildValidationSchema(overrideOptions) {
86
85
  is: function is(val) {
87
86
  return !mpValidationOptions.mp_permissionSMS.disableOption && mpValidationOptions.mp_permissionSMS[val];
88
87
  },
89
- then: yup.string().required('Please enter your mobile number').phone('GB', false, 'Please enter a valid mobile number')
88
+ then: yup.string().required('Please enter your mobile number').matches(phoneRegex, 'Please enter a valid UK mobile number')
90
89
  }),
91
90
  mp_phone: yup.string().when('mp_permissionPhone', {
92
91
  is: function is(val) {
93
92
  return !mpValidationOptions.mp_permissionPhone.disableOption && mpValidationOptions.mp_permissionPhone[val];
94
93
  },
95
- then: yup.string().required('Please enter your phone number').phone('GB', false, 'Please enter a valid phone number')
94
+ then: yup.string().required('Please enter your phone number').matches(phoneRegex, 'Please enter a valid UK phone number')
96
95
  }),
97
96
  mp_address1: yup.string().when('mp_permissionPost', {
98
97
  is: function is(val) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "5.8.3",
4
+ "version": "5.8.4",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -41,8 +41,7 @@
41
41
  "react-uid": "^2.2.0",
42
42
  "styled-components": "^5.3.1",
43
43
  "youtube-player": "^5.5.2",
44
- "yup": "^0.32.9",
45
- "yup-phone": "^1.2.19"
44
+ "yup": "^0.32.9"
46
45
  },
47
46
  "resolutions": {
48
47
  "react-scripts/workbox-webpack-plugin/workbox-build/@surma/rollup-plugin-off-main-thread/ejs": "3.1.6"
@@ -1,5 +1,4 @@
1
1
  import * as yup from 'yup';
2
- import 'yup-phone';
3
2
  import { merge } from 'lodash';
4
3
 
5
4
  const setInitialValues = overrideValues => {
@@ -65,6 +64,8 @@ const buildValidationSchema = overrideOptions => {
65
64
  // Override with any custom options supplied
66
65
  const mpValidationOptions = merge(defaultOptions, overrideOptions);
67
66
 
67
+ const phoneRegex = /^(((((\+44)|(0044))\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((((\+44)|(0044))\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((((\+44)|(0044))\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\\#(\d{4}|\d{3}))?$/;
68
+
68
69
  const mpValidationSchema = yup.object({
69
70
  mp_email: yup.string()
70
71
  .when('mp_permissionEmail', {
@@ -77,14 +78,16 @@ const buildValidationSchema = overrideOptions => {
77
78
  .when('mp_permissionSMS', {
78
79
  is: val => (!(mpValidationOptions.mp_permissionSMS.disableOption)
79
80
  && mpValidationOptions.mp_permissionSMS[val]),
80
- then: yup.string().required('Please enter your mobile number').phone('GB', false, 'Please enter a valid mobile number')
81
+ then: yup.string().required('Please enter your mobile number')
82
+ .matches(phoneRegex, 'Please enter a valid UK mobile number')
81
83
  }),
82
84
 
83
85
  mp_phone: yup.string()
84
86
  .when('mp_permissionPhone', {
85
87
  is: val => (!(mpValidationOptions.mp_permissionPhone.disableOption)
86
88
  && mpValidationOptions.mp_permissionPhone[val]),
87
- then: yup.string().required('Please enter your phone number').phone('GB', false, 'Please enter a valid phone number')
89
+ then: yup.string().required('Please enter your phone number')
90
+ .matches(phoneRegex, 'Please enter a valid UK phone number')
88
91
  }),
89
92
 
90
93
  mp_address1: yup.string()