You can extend the Validator class.

Laravel Doc

But anyway try this

Validator::extend('is_png',function($attribute, $value, $params, $validator) {
    $image = base64_decode($value);
    $f = finfo_open();
    $result = finfo_buffer($f, $image, FILEINFO_MIME_TYPE);
    return $result == 'image/png';
});

And then validate like this:

$rules = array(
   'image' => 'is_png'
);
0