Data URI Rule

Validate Data URI scheme string

117k Downloads / Month

Open Source MIT License

Explore how to validate Data URI scheme strings with the additional validation rules of Intervention Validation for your Laravel application.

public Intervention\Validation\Rules\DataUri::__construct(?array $media_types = null)

The field under validation must be a valid Data URI.

Parameters

media_types (optional)

Parameter to determine the media type to be validated. Can either be null to allow all valid media types or an array of allowed types.

Example

use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\DataUri;

$validator = Validator::make($request->all(), [
    'attribute-key' => new DataUri(),
]);
use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\DataUri;

$validator = Validator::make($request->all(), [
    'attribute-key' => new DataUri([
        'image/jpeg',
        'image/png',
    ]),
]);
Edit