Node JS API : #08 - Input Validation

Publicado em: 24 Setembro 2022
no canal de: 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': 'لا يجوز الاسم يكون اكثر من مئه حروف',
}),
});
--------------------------------------------------------------------------------------------------------------------------


Nesta página do site você pode assistir ao vídeo on-line Node JS API : #08 - Input Validation duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Youssef Abbas 24 Setembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 6,844 vezes e gostou 231 espectadores. Boa visualização!