skip to Main Content

javascript: JOI merge fields conditionally

Haven't found any working solution for my case, so I'm creating a new one. I've got this architecture: function getParts1() { return { common: joi.object({ common_key: joi.number().integer().required(), common_conditional: joi.string().valid("AB", "CD", "EF").required(), common_value1: joi.string().max(144).required(), }), variation1: joi.object({ field1: joi.number().allow(0).required(), field2: joi.string().max(255).allow("").required(),…

VIEW QUESTION

Javascript – Joi validation not working correctly Nodejs

I am trying to validate a schema. its not very complex. below is my code Joi.object({ mobile: Joi.string() .label('mobile') .pattern(/^(+)[1-9]d{7,14}$/) .messages({ 'string.pattern.base': 'Invalid mobile number', }), email: Joi.string() .email({ tlds: { allow: false } }) .label('email') .messages({ 'string.email': 'Invalid email…

VIEW QUESTION
Back To Top
Search