title: How to validate image type and size in JOI react
body: <p>I am trying to validate image type such as <code>png,jpg, jpeg, gif</code> and file size not greater than 2 MB.</p>
  <p>I am using JOI for react validataion, with react hook form.</p>
  <p>I have also tried using <code>joi-image-extension</code> as:</p>
  <pre><code>import BaseJoi from &quot;joi&quot;;
  const ImageExtension = require(&quot;joi-image-extension&quot;);
  import { joiResolver } from &quot;@hookform/resolvers/joi&quot;;
  
  const Joi = BaseJoi.extend(ImageExtension);
  
  const CollectionForm = () =&gt; {
       const schema = Joi.object({
          over_image: Joi.image().label(&quot;Cover Image&quot;),
       });
  }
  </code></pre>
  <p>But it showing, <code>app.js:15659 Uncaught Error: Cannot find module 'fs'</code></p>
  <p>All, I want is to validate this image type <code>png,jpg,jpeg,gif</code> and file size for less than 2MB using any JOI extension or custom JOI validataion for react (react hook form)</p>