# Joi.validate is deprecated

**URL:** <https://forum.codewithmosh.com/t/joi-validate-is-deprecated/25135>\
**Category:** Node\
**Created:** [February 16, 2024, 1:01am UTC](https://forum.codewithmosh.com/t/joi-validate-is-deprecated/25135 "2024-02-16T01:01:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theorion](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/theorion/32/7783_2.png) [@theorion](https://forum.codewithmosh.com/u/theorion)\
**Post date:** [February 16, 2024, 1:01am UTC](https://forum.codewithmosh.com/t/joi-validate-is-deprecated/25135/1 "2024-02-16T01:01:19Z")

</div>

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;

}

```

---

<div class="post-metadata">

**Author:** ![theorion](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/theorion/32/7783_2.png) [@theorion](https://forum.codewithmosh.com/u/theorion)\
**Post date:** [February 16, 2024, 1:01am UTC](https://forum.codewithmosh.com/t/joi-validate-is-deprecated/25135/2 "2024-02-16T01:01:28Z")

</div>

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;
}

```
