title: Mongoose - array of enum strings
body: <p>I have a Schema that has a property with the type of array of strings that are predefined.</p>
  <p>This is what I've tried to do:</p>
  <pre class="lang-js prettyprint-override"><code>interests: {
      type: [String],
      enum: ['football', 'basketball', 'read'],
      required: true
  }
  </code></pre>
  <p>The thing is that when I'm trying to enter a wrong value that isn't defined on the enum, to the array it wouldn't validate it with the enum list.</p>
  <p>for example, this would pass which it shouldn't:</p>
  <pre class="lang-js prettyprint-override"><code>{ &quot;interests&quot;: [&quot;football&quot;, &quot;asdf&quot;] }
  </code></pre>
  <p>because <code>&quot;asdf&quot;</code> isn't predefined in the enum list it shouldn't pass the validation but unfortunately, it passes the validation and saves it.</p>
  <p>I've tried to check this thing with a string type of values instead of an array of strings and it works.</p>
  <p>for example:</p>
  <pre class="lang-js prettyprint-override"><code>interests: {
      type: String,
      enum: ['football', 'basketball', 'read'],
      required: true
  }
  </code></pre>
  <p>for example, this is failing as expected:</p>
  <pre class="lang-js prettyprint-override"><code>{ &quot;interest&quot;: &quot;asdf&quot; }
  </code></pre>
  <p>In conclusion, I need a schema's property with a type of array of strings that would check it's elements based on predefined values</p>
  <p>Is the most effective way to achieve this goal is by using the validate method or there is a better way?</p>