mirror of
https://github.com/koel/koel
synced 2024-11-28 06:50:27 +00:00
21 lines
481 B
PHP
21 lines
481 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ImageData implements Rule
|
|
{
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return attempt(static function () use ($value) {
|
|
return (bool) preg_match('/data:image\/(jpe?g|png|webp|gif)/i', Str::before($value, ';'));
|
|
}, false) ?? false;
|
|
}
|
|
|
|
public function message(): string
|
|
{
|
|
return 'Invalid DataURL string';
|
|
}
|
|
}
|