Joi.validate is deprecated

i’m trying this but the console is saying invalid message options

app.post(‘/api/courses’, (req, res) => {
const schema = Joi.object ({
name: Joi.string().min(3)
});

 const result = schema.validate(req.body, schema);    
if (result.error) {
    res.status(400).send('Validation failed: ' + result.error.details[0].message)
return;

}

just solved it by looking at documentation, need Joi.object after schema and put name inside the block. then change joi.validate to schema.validate and remove schema in the function

app.post(‘/api/courses’, (req, res) => {
const schema = Joi.object ({
name: Joi.string().min(3).required()
});

 const result = schema.validate(req.body);    
if (result.error) {
    res.status(400).send('Validation failed: ' + result.error.details[0].message)
return;
}