title: how to fix ".... validation failed" using postman with express/bodyParser
body: <p><a href="https://i.stack.imgur.com/QfCuC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QfCuC.jpg" alt="enter image description here"></a>I am making an API using express/bodyparser/MongoDB/postman, but whenever i send a POST request the Schema returns an error, how can i fix this issue?</p>
  
  <p>I've tried different options in Postman, like checking if I had the right options and making sure its set to JSON.</p>
  
  <p>How my requirements look:</p>
  
  <pre><code>const express = require("express");
  const app = express();
  const todoRoutes = require("./routes/todos");
  const bodyParser = require("body-parser");
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  </code></pre>
  
  <p>What my Schema looks like:</p>
  
  <pre><code>var todoSchema = new mongoose.Schema({
    name: {
      type: String,
      required: "Use a string"
    },
    completed: {
      type: Boolean,
      default: false
    },
  created_date: {
    type: Date,
    default: Date.now
  }
  });
  
  </code></pre>
  
  <p>How my POST request looks:</p>
  
  <pre><code>router.post("/",function(req,res){
    console.log(req.body);
  db.Todo.create(req.body)
  .then(function(newTodo){
    res.json(newTodo);
  })
  .catch(function(err){
    res.send(err);
  });
  });
  </code></pre>
  
  <p>The error which is returned by Postman:</p>
  
  <pre><code>{
      "errors": {
          "name": {
              "message": "Use a string",
              "name": "ValidatorError",
              "properties": {
                  "message": "Use a string",
                  "type": "required",
                  "path": "name"
              },
              "kind": "required",
              "path": "name"
          }
      },
      "_message": "Todo validation failed",
      "message": "Todo validation failed: name: Use a string",
      "name": "ValidationError"
  }
  
  </code></pre>
  
  <p>And the console.log of req.body when i give a key of name and a value of GoT :</p>
  
  <pre><code>'{\n "name" : "watch GoT"\n}': " }
  
  </code></pre>
  
  <p>The main odd thing which i see is that for some reason I get a strange log from req.body in the first place ( unusual ' and \n)</p>