Mimetype

February 3, 2026 ยท View on GitHub

  • Mimetype(string $mimetype)

Validates if the input is a file and if its MIME type matches the expected one.

v::mimetype('image/png')->assert('/path/to/image.png');
// Validation passes successfully

v::mimetype('image/jpeg')->assert('/path/to/image.jpg');
// Validation passes successfully

This validator is case-sensitive and requires fileinfo PHP extension.

Templates

Mimetype::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must have the {{mimetype}} MIME type
inverted{{subject}} must not have the {{mimetype}} MIME type

Template placeholders

PlaceholderDescription
mimetype
subjectThe validated input or the custom validator name (if specified).

Categorization

  • File system

Changelog

VersionDescription
1.0.0Created

See Also