Intervention / validation

Missing Laravel Validation Rules
https://validation.intervention.io
MIT License
590 stars 67 forks source link

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

Closed Temepest74 closed 11 months ago

Temepest74 commented 2 years ago

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

crichardson9 commented 1 year ago

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());
        }
    }
],
olivervogel commented 11 months ago

Version 4 allows to check for mime-types.