title: Validation error for array using axios mongodb
body: <p>My Article Schema contains tags field.</p>
  <pre><code>tags: {
    type: [String],
    required: [true, &quot;A article must have a tags&quot;],
    enum: {
      values: [
        &quot;science&quot;,
        &quot;technology&quot;,
        &quot;gaming&quot;,
     ],
      message: &quot;Article must have tags&quot;,
    },
  },
  </code></pre>
  <p>My  Pug Template for that specific field inside the form</p>
  <pre><code> input#checkbox1(type=&quot;checkbox&quot;, name=&quot;science&quot;, value=&quot;science&quot;)
   | science 
   br
   input#checkbox2(type=&quot;checkbox&quot;, name=&quot;technology&quot;, value=&quot;technology&quot;)
   | technology
   br
   input#checkbox3(type=&quot;checkbox&quot;, name=&quot;gaming&quot;, value=&quot;gaming&quot;)
   | gaming
   
  </code></pre>
  <p>My javaScript file to handle POST request for sending data to the axios function in postArticle.js</p>
  <pre><code>const composeArticle = document.querySelector(&quot;.formComposePost&quot;);
  if (composeArticle) {
    composeArticle.addEventListener(&quot;submit&quot;, (e) =&gt; {
      e.preventDefault();
      const form = new FormData();
      form.append(&quot;author&quot;, document.getElementById(&quot;userid&quot;).value);
      form.append(&quot;title&quot;, document.getElementById(&quot;heading&quot;).value);
      let tagArray = [];
      let science = document.getElementById(&quot;checkbox1&quot;);
      if (science.checked) {
        tagArray.push(science.value);
      }
      let technology = document.getElementById(&quot;checkbox2&quot;);
      if (technology.checked) {
        tagArray.push(technology.value);
      }
      let gaming = document.getElementById(&quot;checkbox3&quot;);
      if (gaming.checked) {
        tagArray.push(gaming.value);
      }
  
      form.append(&quot;tags&quot;, tagArray);
      form.append(
        &quot;imageCover&quot;,
        document.getElementById(&quot;image&quot;).files[0]
      );
  
      postArticle(form);
  </code></pre>
  <p>PostArticle handler function
  I'm using axios to post the data to the API
  but I can't post the data</p>
  <pre><code>export const postArticle = async (data) =&gt; {
    try {
      const res = await axios({
        method: &quot;POST&quot;,
        url: &quot;http://127.0.0.1:3000/api/v1/articles/&quot;,
        data,
      });
      console.log(res);
      if (res.data.status === &quot;success&quot;) {
        alert(&quot;success&quot;)
        window.setTimeout(() =&gt; {
          location.assign(&quot;/&quot;);
        }, 1000);
      }
    } catch (error) {
      console.log(error.response.data.message);
    }
  };
  </code></pre>
  <p>my error message in the console after i submit the form</p>
  <pre><code>message: 'Article validation failed: tags.0: Article must have tags'
  </code></pre>