Intervention / validation

Missing Laravel Validation Rules

Home Page:https://validation.intervention.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: and mime, size and charset check to Data Uri

Temepest74 opened this issue · comments

The title. It will be so much helpful to have it already build in

I'm not sure if it helps, but here's what I'm doing currently:

'image' => [
    'nullable',
    new DataUri(),
    'bail',
    function ($attribute, $value, $fail) {
        try {
            $image = Image::make($value);
            if (!$image || !str_starts_with($image->mime(), 'image/')) {
                $fail('The '.$attribute.' must be an image.');
            }
        } catch (\Exception $exception) {
            $fail($exception->getMessage());
        }
    }
],

Version 4 allows to check for mime-types.