Create validateParoles
This commit is contained in:
@@ -91,9 +91,25 @@ const translateTeks = async teksFR => {
|
||||
}
|
||||
}
|
||||
|
||||
const validateParoles = (tit, transkripsyon) => {
|
||||
if (!tit || tit.trim().length === 0) {
|
||||
throw new ValidationError('Champ obligatoire. Veuillez choisir un titre.');
|
||||
}
|
||||
|
||||
if (!transkripsyon || transkripsyon.trim().length === 0) {
|
||||
throw new ValidationError('Champ obligatoire. Veuillez renseigner la transcription.')
|
||||
}
|
||||
|
||||
if (transkripsyon.trim().length < 10) {
|
||||
throw new ValidationError('La transcription doit contenir au moins 10 caractères.')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beforeCreate: async event => {
|
||||
let {data} = event.params
|
||||
validateParoles(data.tit, data.transkripsyon)
|
||||
|
||||
const user = await jwennUserEpiId(data?.user?.id)
|
||||
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
||||
|
||||
@@ -120,6 +136,8 @@ module.exports = {
|
||||
},
|
||||
beforeUpdate: async event => {
|
||||
let {data} = event.params
|
||||
validateParoles(data.tit, data.transkripsyon)
|
||||
|
||||
const {where} = event.params
|
||||
|
||||
if(!data.publishedAt) {
|
||||
|
||||
Reference in New Issue
Block a user