title: How can I validate maxlength of a array of strings in mongoose schema?
body: <pre><code>const mongoose = require('mongoose');
  //var validate = require('mongoose-validator');
  const postschema = mongoose.Schema({ 
      userName :{
          type : String,
          required : true
      },
      status : {
          type : Array ,
          items : {
              type : String ,
              max: 20 ,
              required : true
          },
      },
      likes : {
          type : Array ,
          default : []
      }
  },
  { timestamps :{ createdAt: 'created_at',updatedAt: 'updated_at' }}
  );
  
  postschema.path('status').validate(function(v){
      return v.length &lt;=20;
  },&quot;The maximum length is 20 &quot;);
  
  module.exports = mongoose.model('Post' , postschema);
  </code></pre>
  <p>My validation function is not working . How can I validate my status Array of String. I want to validate each string of 20 characters</p>