Node JS API : #08 - Input Validation

Publié le: 24 septembre 2022
sur la chaîne: Youssef Abbas
6,844
231

In this part we validate the data that comes from the client with Joi package.

If you want to have custom message with Joi you should use messages() method.
Example:
------------------------------------------------------------------------------------------------------------------------
const schema = Joi.object({
username: Joi.string().trim().min(3).max(100).required().messages({
'any.required': 'الاسم مطلوب',
'string.base': 'الاسم لازم يكون من نوع نص',
'string.empty': 'رجاء ادخال الاسم',
'string.min': 'لا يجوز الاسم يكون اقل من ثلاثة حروف',
'string.max': 'لا يجوز الاسم يكون اكثر من مئه حروف',
}),
});
--------------------------------------------------------------------------------------------------------------------------


Sur cette page du site, vous pouvez voir la vidéo en ligne Node JS API : #08 - Input Validation durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Youssef Abbas 24 septembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 6,844 fois et il a aimé 231 téléspectateurs. Bon visionnage!