fix: parent's email, telephone validation

This commit is contained in:
Sebastian Pravda 2022-12-25 21:26:24 +01:00
parent 326aef5483
commit 54752a50d3
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57

View file

@ -71,7 +71,7 @@
gdpr: yup.boolean().oneOf([true]),
candidate: yup.object().shape({
name: yup.string().required(),
surname: yup.string(),
surname: yup.string().required(),
email: yup.string().email().required(),
telephone: yup
.string()
@ -106,13 +106,13 @@
.string()
.email()
.test((_val, context) => {
if (context.path.includes('parents[1]')) {
if (context.path.includes('parents[1]') && _val === '') {
return true;
}
return _val !== '';
}),
telephone: yup.string().test((_val, context) => {
if (context.path.includes('parents[1]')) {
if (context.path.includes('parents[1]') && _val === '') {
return true;
}
return _val?.match(/^\+\d{1,3} \d{3} \d{3} \d{3}$/) !== null;