@comicrelief/component-library 8.0.0 → 8.0.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.
@@ -69,31 +69,31 @@ const buildValidationSchema = overrideOptions => {
69
69
  const mpValidationFields = {
70
70
  mp_email: yup.string().when('mp_permissionEmail', {
71
71
  is: val => !mpValidationOptions.mp_permissionEmail.disableOption && mpValidationOptions.mp_permissionEmail[val],
72
- then: yup.string().required('Please enter your email address').email('Please enter a valid email address')
72
+ then: schema => schema.required('Please enter your email address').email('Please enter a valid email address')
73
73
  }),
74
74
  mp_mobile: yup.string().when('mp_permissionSMS', {
75
75
  is: val => !mpValidationOptions.mp_permissionSMS.disableOption && mpValidationOptions.mp_permissionSMS[val],
76
- then: yup.string().required('Please enter your mobile number').matches(phoneRegex, 'Please enter a valid UK mobile number')
76
+ then: schema => schema.required('Please enter your mobile number').matches(phoneRegex, 'Please enter a valid UK mobile number')
77
77
  }),
78
78
  mp_phone: yup.string().when('mp_permissionPhone', {
79
79
  is: val => !mpValidationOptions.mp_permissionPhone.disableOption && mpValidationOptions.mp_permissionPhone[val],
80
- then: yup.string().required('Please enter your phone number').matches(phoneRegex, 'Please enter a valid UK phone number')
80
+ then: schema => schema.required('Please enter your phone number').matches(phoneRegex, 'Please enter a valid UK phone number')
81
81
  }),
82
82
  mp_address1: yup.string().when('mp_permissionPost', {
83
83
  is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
84
- then: yup.string().required('Please enter the first line of your address').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
84
+ then: schema => schema.required('Please enter the first line of your address').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
85
85
  }),
86
86
  mp_town: yup.string().when('mp_permissionPost', {
87
87
  is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
88
- then: yup.string().required('Please enter your town').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
88
+ then: schema => schema.required('Please enter your town').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
89
89
  }),
90
90
  mp_postcode: yup.string().when('mp_permissionPost', {
91
91
  is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
92
- then: yup.string().required('Please enter your postcode').matches(/^[a-zA-Z]{1,2}\d[a-zA-Z\d]?\s*\d[a-zA-Z]{2}$/, 'Please enter a valid postcode')
92
+ then: schema => schema.required('Please enter your postcode').matches(/^[a-zA-Z]{1,2}\d[a-zA-Z\d]?\s*\d[a-zA-Z]{2}$/, 'Please enter a valid postcode')
93
93
  }),
94
94
  mp_country: yup.string().when('mp_permissionPost', {
95
95
  is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
96
- then: yup.string().required('Please enter your country').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
96
+ then: schema => schema.required('Please enter your country').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
97
97
  }),
98
98
  /* Non-required fields */
99
99
  mp_address2: yup.string().max(50, 'Please enter a maximum of 50 characters'),
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": "8.0.0",
4
+ "version": "8.0.1",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -68,14 +68,14 @@ const buildValidationSchema = overrideOptions => {
68
68
  .when('mp_permissionEmail', {
69
69
  is: val => (!(mpValidationOptions.mp_permissionEmail.disableOption)
70
70
  && mpValidationOptions.mp_permissionEmail[val]),
71
- then: yup.string().required('Please enter your email address').email('Please enter a valid email address')
71
+ then: schema => schema.required('Please enter your email address').email('Please enter a valid email address')
72
72
  }),
73
73
 
74
74
  mp_mobile: yup.string()
75
75
  .when('mp_permissionSMS', {
76
76
  is: val => (!(mpValidationOptions.mp_permissionSMS.disableOption)
77
77
  && mpValidationOptions.mp_permissionSMS[val]),
78
- then: yup.string().required('Please enter your mobile number')
78
+ then: schema => schema.required('Please enter your mobile number')
79
79
  .matches(phoneRegex, 'Please enter a valid UK mobile number')
80
80
  }),
81
81
 
@@ -83,7 +83,7 @@ const buildValidationSchema = overrideOptions => {
83
83
  .when('mp_permissionPhone', {
84
84
  is: val => (!(mpValidationOptions.mp_permissionPhone.disableOption)
85
85
  && mpValidationOptions.mp_permissionPhone[val]),
86
- then: yup.string().required('Please enter your phone number')
86
+ then: schema => schema.required('Please enter your phone number')
87
87
  .matches(phoneRegex, 'Please enter a valid UK phone number')
88
88
  }),
89
89
 
@@ -91,7 +91,7 @@ const buildValidationSchema = overrideOptions => {
91
91
  .when('mp_permissionPost', {
92
92
  is: val => (!(mpValidationOptions.mp_permissionPost.disableOption)
93
93
  && mpValidationOptions.mp_permissionPost[val]),
94
- then: yup.string().required('Please enter the first line of your address')
94
+ then: schema => schema.required('Please enter the first line of your address')
95
95
  .matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character')
96
96
  .max(50, 'Please enter a maximum of 50 characters')
97
97
  }),
@@ -100,7 +100,7 @@ const buildValidationSchema = overrideOptions => {
100
100
  .when('mp_permissionPost', {
101
101
  is: val => (!(mpValidationOptions.mp_permissionPost.disableOption)
102
102
  && mpValidationOptions.mp_permissionPost[val]),
103
- then: yup.string().required('Please enter your town')
103
+ then: schema => schema.required('Please enter your town')
104
104
  .matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character')
105
105
  .max(50, 'Please enter a maximum of 50 characters')
106
106
  }),
@@ -108,13 +108,13 @@ const buildValidationSchema = overrideOptions => {
108
108
  mp_postcode: yup.string().when('mp_permissionPost', {
109
109
  is: val => (!(mpValidationOptions.mp_permissionPost.disableOption)
110
110
  && mpValidationOptions.mp_permissionPost[val]),
111
- then: yup.string().required('Please enter your postcode').matches(/^[a-zA-Z]{1,2}\d[a-zA-Z\d]?\s*\d[a-zA-Z]{2}$/, 'Please enter a valid postcode')
111
+ then: schema => schema.required('Please enter your postcode').matches(/^[a-zA-Z]{1,2}\d[a-zA-Z\d]?\s*\d[a-zA-Z]{2}$/, 'Please enter a valid postcode')
112
112
  }),
113
113
 
114
114
  mp_country: yup.string().when('mp_permissionPost', {
115
115
  is: val => (!(mpValidationOptions.mp_permissionPost.disableOption)
116
116
  && mpValidationOptions.mp_permissionPost[val]),
117
- then: yup.string().required('Please enter your country')
117
+ then: schema => schema.required('Please enter your country')
118
118
  .matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character')
119
119
  .max(50, 'Please enter a maximum of 50 characters')
120
120
  }),