Node JS API : #08 - Input Validation

Pubblicato il: 24 settembre 2022
sul canale di: 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': 'لا يجوز الاسم يكون اكثر من مئه حروف',
}),
});
--------------------------------------------------------------------------------------------------------------------------


In questa pagina del sito puoi guardare il video online Node JS API : #08 - Input Validation della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Youssef Abbas 24 settembre 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 6,844 volte e gli è piaciuto 231 spettatori. Buona visione!