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
| Mode | Template |
|---|---|
default | {{subject}} must have the {{mimetype}} MIME type |
inverted | {{subject}} must not have the {{mimetype}} MIME type |
Template placeholders
| Placeholder | Description |
|---|---|
mimetype | |
subject | The validated input or the custom validator name (if specified). |
Categorization
- File system
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Created |