Yii2 validate image post as data url
<p>I need to validate image uploaded as data url which is in form:</p>

<pre><code>{profile: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAA...McAAAAASUVORK5CYII="}
</code></pre>

<p>my Profile model has following rules:</p>

<pre><code>    return [
        ...
        ['profile', 'image', 'extensions' =&gt; 'png, jpg',
            'minWidth' =&gt; 50, 'maxWidth' =&gt; 150,
            'minHeight' =&gt; 50, 'maxHeight' =&gt; 150,
        ],
        ...
     ];
</code></pre>

<p>my controller is saving the profile without validation:</p>

<pre><code>        $my=new Profile();
        $my-&gt;profile=Yii::$app-&gt;request-&gt;post("profile");
        $result=$my-&gt;save(); //Always true even when dimensions are out of bound.
</code></pre>

<p><strong>Problem:</strong>
The image validation is not working for post data with image as string (data url).</p>

<p>Please help validate the image.</p>

<p><strong>Update:</strong>
<a href="https://stackoverflow.com/questions/12658661">Other question</a> mentioned as duplicate is not related to Yii2 framework. I am looking for answer which will follow the MVC flow of Yii2.</p>