Model
const hoursSchema = new Schema({
    date: {
        type: Date,
        required: true,
        trim: true,
    },
    location: {
        type: String,
        required: true,
        trim: true,
        minlength: 1,
    }
});
module.exports = mongoose.model('Hours', hoursSchema);
Route
router.post('/', (req, res) => {
   const body = _.pick(req.body, ['date', 'location']);
   const entry = new Hours(body);
   res.send(entry);
   // rest of code...
});
I make a post request with let's say date: 12 / date: "12". Mongoose is treating this a a timestamp because I've receiving this as a result in date field - 1970-01-01T00:00:00.012Z. How can I prevent that? I want to throw an error when user send other data than date in format yyyy-mm-dd or dd-mm-yyyy
 
    