diff --git a/src/components/Asset/Edit/_validation.ts b/src/components/Asset/Edit/_validation.ts index 52b9faf07..8d81768fe 100644 --- a/src/components/Asset/Edit/_validation.ts +++ b/src/components/Asset/Edit/_validation.ts @@ -10,7 +10,15 @@ export const validationSchema = Yup.object().shape({ files: Yup.array() .of( Yup.object().shape({ - url: Yup.string().url('Must be a valid URL.'), + url: Yup.string() + .url('Must be a valid URL.') + .test( + 'GoogleNotSupported', + 'Google Drive is not a supported hosting service. Please use an alternative.', + (value) => { + return !value?.toString().includes('drive.google') + } + ), valid: Yup.boolean().isTrue() }) ) @@ -18,7 +26,15 @@ export const validationSchema = Yup.object().shape({ links: Yup.array() .of( Yup.object().shape({ - url: Yup.string().url('Must be a valid URL.'), + url: Yup.string() + .url('Must be a valid URL.') + .test( + 'GoogleNotSupported', + 'Google Drive is not a supported hosting service. Please use an alternative.', + (value) => { + return !value?.toString().includes('drive.google') + } + ), valid: Yup.boolean().isTrue() }) ) diff --git a/src/components/Publish/_validation.ts b/src/components/Publish/_validation.ts index 3454f50ba..7d76bdcc6 100644 --- a/src/components/Publish/_validation.ts +++ b/src/components/Publish/_validation.ts @@ -32,7 +32,17 @@ const validationService = { files: Yup.array() .of( Yup.object().shape({ - url: Yup.string().url('Must be a valid URL.').required('Required'), + url: Yup.string() + .test( + 'GoogleNotSupported', + 'Google Drive is not a supported hosting service. Please use an alternative.', + (value) => { + return !value?.toString().includes('drive.google') + } + ) + .url('Must be a valid URL.') + .required('Required'), + valid: Yup.boolean().isTrue().required('File must be valid.') }) ) @@ -41,7 +51,15 @@ const validationService = { links: Yup.array() .of( Yup.object().shape({ - url: Yup.string().url('Must be a valid URL.'), + url: Yup.string() + .url('Must be a valid URL.') + .test( + 'GoogleNotSupported', + 'Google Drive is not a supported hosting service. Please use an alternative.', + (value) => { + return !value?.toString().includes('drive.google') + } + ), // TODO: require valid file only when URL is given valid: Yup.boolean() // valid: Yup.boolean().isTrue('File must be valid.')