Joi Schema should contain one or another chema

Viewed 14

I'm looking into using Joi for api validation.

So it must be like one or another chema

Joi.object({
            email: Joi.string().required(),
            notes: Joi.object({
                title: Joi.string().required(),
                details: Joi.string().required()
            })
        })

try for another

Joi.object({
            first_name: Joi.string().prefs({ convert: false }),
            last_name: Joi.string().prefs({ convert: false }),
            cell_phone_1: Joi.number().min(1e9).max(9999999999).prefs({ convert: false }),
        }).or('first_name', 'last_name'))

Thanks

0 Answers
Related