title: Mongoose: Built in validations on additional properties of SchemaType not working like min, max, minlength, maxlength etc
body: <p>I am new to mongoose (MongoDB) and Nodejs, i am creating RestFul services for CRUD operations, however my issue is, for the Schema expression, the SchemaType additional properties are not being considered in the built in validation of mongoose where as it is considering required property only. Please find my model below for your reference: </p>
  
  <pre><code>const mongoose = require('mongoose');
  const Schema = mongoose.Schema;
  
  let ProductSchema = new Schema({
      name: {
              type: String, 
              required: true, 
              minlength:2,
              maxlength:10 
            },
      price:{
              type: Number, 
              required:true,
              min:2, 
              max:100
            }, 
  })
  
  //Export the model
  
  module.exports = mongoose.model('Product', ProductSchema);
  </code></pre>
  
  <p>So in the above model, There are properties like min, max for Number data Type and minlength and maxLength for String data Type which are not at all considered for the validation to take place before saving into the MongoDB. </p>
  
  <p>Am i missing any configuration in this? i have gone through the mongoose documentation and also through the stackoverflow's lot of posts but i did not get any information regarding this particularly. </p>
  
  <p>Here is my controller as well:</p>
  
  <pre><code>const Product = require('../models/product.model');
  
  // Simple version, without validation or sanitation
  
  exports.test = function (req,res) {
      res.send('Greetings from the Test Controller!');
  };
  
  exports.product_create = function (req,res,next) {
      let product = new Product(
              {
                  name: req.body.name,
                  price: req.body.price
              }
          );
  
      product.save(function (err) {
                  if(err){
                      return next(err);
                  }
                  res.send('Product created Successfully');
              }
      )
  
  };
  
  exports.product_details = function (req,res, next) {
      Product.findById(req.params.id, function (err, product){
          if(err) {
              return next(err);
          }
          res.send(product);
      }) 
  };
  
  exports.product_update = function (req, res, next) {
      Product.findOneAndUpdate(req.params.id, {$set: req.body},opts, function (err, product){
          if(err) return next(err);
          res.send('Product Updated');
      })
  };
  
  exports.product_delete = function (req,res,next) {
      Product.findOneAndRemove(req.params.id, function (err) {
          if(err) return next(err);
          res.send('Deleted product');
      })
  };
  </code></pre>
  
  <p>Please guide me if i am missing something, still that needs to incorporate into it. Thanks.</p>