Create validateParoles

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-14 19:51:35 +04:00
parent f8cef5e7a5
commit 620f6cb1d9
@@ -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) {