- added LicenseController.ts and MimetypeController for enabling mime_types and licences
Some checks failed
CI Pipeline / japa-tests (push) Failing after 58s

- add new authors and contributors only by unique email addresses
- allow multiple file upload
- added validation rule for validating length of uploaded files
- modified Dockerfile for starting "bin/server.js" instead of *server.js"
- npm updates
This commit is contained in:
Kaimbacher 2024-06-14 12:38:04 +02:00
parent 770e791613
commit ac473b1e72
27 changed files with 1720 additions and 914 deletions

View file

@ -55,18 +55,24 @@ export const createDatasetValidator = vine.compile(
authors: vine
.array(
vine.object({
email: vine.string().trim().maxLength(255).email().normalizeEmail(),
email: vine.string().trim().maxLength(255).email().normalizeEmail().isUniquePerson({ table: 'persons', column: 'email', idField: 'id' }),
first_name: vine.string().trim().minLength(3).maxLength(255),
last_name: vine.string().trim().minLength(3).maxLength(255),
}),
)
.minLength(1),
.minLength(1)
.distinct('email'),
contributors: vine
.array(
vine.object({
email: vine.string().trim().maxLength(255).email().normalizeEmail(),
email: vine.string().trim().maxLength(255).email().normalizeEmail().isUniquePerson({ table: 'persons', column: 'email', idField: 'id' }),
first_name: vine.string().trim().minLength(3).maxLength(255),
last_name: vine.string().trim().minLength(3).maxLength(255),
pivot_contributor_type: vine.enum(Object.keys(ContributorTypes)),
}),
)
.optional(),
.distinct('email')
.optional(),
// third step
project_id: vine.number().optional(),
// embargo_date: schema.date.optional({ format: 'yyyy-MM-dd' }, [rules.after(10, 'days')]),
@ -114,10 +120,10 @@ export const createDatasetValidator = vine.compile(
// last step
files: vine
.array(
vine.file({
vine.myfile({
size: '512mb',
extnames: extensions,
}),
}).filenameLength({ clientNameSizeLimit : 100 }),
)
.minLength(1),
}),
@ -169,17 +175,23 @@ export const updateDatasetValidator = vine.compile(
authors: vine
.array(
vine.object({
email: vine.string().trim().maxLength(255).email().normalizeEmail(),
email: vine.string().trim().maxLength(255).email().normalizeEmail().isUniquePerson({ table: 'persons', column: 'email', idField: 'id' }),
first_name: vine.string().trim().minLength(3).maxLength(255),
last_name: vine.string().trim().minLength(3).maxLength(255),
}),
)
.minLength(1),
.minLength(1)
.distinct('email'),
contributors: vine
.array(
vine.object({
email: vine.string().trim().maxLength(255).email().normalizeEmail(),
email: vine.string().trim().maxLength(255).email().normalizeEmail().isUniquePerson({ table: 'persons', column: 'email', idField: 'id' }),
first_name: vine.string().trim().minLength(3).maxLength(255),
last_name: vine.string().trim().minLength(3).maxLength(255),
pivot_contributor_type: vine.enum(Object.keys(ContributorTypes)),
}),
)
.distinct('email')
.optional(),
// third step
project_id: vine.number().optional(),
@ -228,7 +240,7 @@ export const updateDatasetValidator = vine.compile(
// last step
files: vine
.array(
vine.file({
vine.myfile({
size: '512mb',
extnames: extensions,
}),
@ -270,7 +282,9 @@ let messagesProvider = new SimpleMessagesProvider({
'The language of the translated description must be different from the language of the dataset',
'authors.array.minLength': 'at least {{ min }} author must be defined',
'authors.distinct': 'The {{ field }} array must have unique values based on the {{ fields }} attribute.',
'contributors.*.pivot_contributor_type.required': 'contributor type is required, if defined',
'contributors.distinct': 'The {{ field }} array must have unique values based on the {{ fields }} attribute.',
'after': `{{ field }} must be older than ${dayjs().add(10, 'day')}`,