title: ValidationError: Post validation failed: title: Path `title` is required. in nodejs api
body: <p>I am making a restful API using nodejs. Here I have added multer for file upload before implementing multer it was working fine but now whenever I try to create post using <code>postman</code> i get error somthing like this.</p>
  
  <blockquote>
    <p>error</p>
  </blockquote>
  
  <pre><code>{ ValidationError: Post validation failed: title: Path `title` is required.
      at ValidationError.inspect (C:\projects\adi-site\api\node_modules\mongoose\l
  ib\error\validation.js:59:24)
      at formatValue (internal/util/inspect.js:490:31)
      at inspect (internal/util/inspect.js:191:10)
      at Object.formatWithOptions (util.js:84:12)
      at Console.(anonymous function) (console.js:188:15)
      at Console.log (console.js:199:31)
      at post.save.then.catch.err (C:\projects\adi-site\api\src\routes\posts.js:70
  :17)
      at process._tickCallback (internal/process/next_tick.js:68:7)
    errors:
     { title:
        { ValidatorError: Path `title` is required.
            at new ValidatorError (C:\projects\adi-site\api\node_modules\mongoose\lib\error\validator.js:29:11)
            at validate (C:\projects\adi-site\api\node_modules\mongoose\lib\schematype.js:975:13)
            at C:\projects\adi-site\api\node_modules\mongoose\lib\schematype.js:1028:11
            at Array.forEach (&lt;anonymous&gt;)
            at SchemaString.SchemaType.doValidate (C:\projects\adi-site\api\node_modules\mongoose\lib\schematype.js:984:19)
            at C:\projects\adi-site\api\node_modules\mongoose\lib\document.js:2098:9
            at process._tickCallback (internal/process/next_tick.js:61:11)
  </code></pre>
  
  <blockquote>
    <p>and when i try to <code>log</code> req.body i get this</p>
  </blockquote>
  
  <pre><code>[Object: null prototype] {
    'title ': 'this is title with imahih',  &lt;-----//i think here `key` title is in the wrong format I have no idea where it is coming from and how to fix this.
    overview: 'this is overview of the image',
    content: 'this is image content' }
  </code></pre>
  
  <blockquote>
    <p>routes/posts.js &lt;-- this is my code</p>
  </blockquote>
  
  <pre><code>router.post('/', upload.single('postImage'),(req, res, next) =&gt; {
      console.log(req.body);
      const post = new Post({
          _id: new mongoose.Types.ObjectId(),
          title: req.body.title,
          overview: req.body.overview,
          content: req.body.content,
          postImage: req.file.path
      });
      post.save().then(result =&gt; {
          console.log(result);
          res.status(201).json({
              message: "Post created",
              createdPost: {
                  _id: result._id,
                  title: result.title,
                  overview: result.overview,
                  content: result.content,
                  postImage: result.postImage
              }
          })
      }).catch(err =&gt; {   
          console.log(err);
          res.status(500).json({
              error: err
          })
      })
  })
  </code></pre>
  
  <blockquote>
    <p>this is how i am sending request</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/qucub.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qucub.png" alt="error-image"></a></p>