Node JS API : #08 - Input Validation

Published: 24 September 2022
on channel: 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': 'لا يجوز الاسم يكون اكثر من مئه حروف',
}),
});
--------------------------------------------------------------------------------------------------------------------------


On this page of the site you can watch the video online Node JS API : #08 - Input Validation with a duration of hours minute second in good quality, which was uploaded by the user Youssef Abbas 24 September 2022, share the link with friends and acquaintances, this video has already been watched 6,844 times on youtube and it was liked by 231 viewers. Enjoy your viewing!