title: How to use node-module 'Validator' in node.js?
body: <p>I have installed and imported validator module in the node js file.</p>
  <p>I want to validate the User's phone number using npm module &quot;Validator&quot; I have written the code as below but it is <strong>Not Working</strong>. It is inside of the schema</p>
  <pre><code>phone: {
      type: Number,
      required: true,
      unique:true,
      validate(value) {
        if(!validator.isMobilePhone(value)){
          throw new error (&quot;Please enter valid phone number&quot;)
      }
    }
  </code></pre>
  <p>It is saving all the invalid phone numbers as well like jist : 1234.</p>
  <p>How to solve this?</p>