1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Checking for google drive links (#1757)

* checking for google drive links

* Removing unused function

* Update src/components/Publish/_validation.ts

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>

* CHecking for google drive URLs on the edit form

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
Jamie Hewitt 2022-11-01 18:00:07 +03:00 committed by GitHub
parent 6d0ce2d708
commit d1e3fa9afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 4 deletions

View File

@ -10,7 +10,15 @@ export const validationSchema = Yup.object().shape({
files: Yup.array<FileInfo[]>()
.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<FileInfo[]>()
.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()
})
)

View File

@ -32,7 +32,17 @@ const validationService = {
files: Yup.array<FileInfo[]>()
.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<FileInfo[]>()
.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.')