Extension

February 3, 2026 ยท View on GitHub

  • Extension(string $extension)

Validates if the file extension matches the expected one:

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

This validator is case-sensitive.

Templates

Extension::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must have the {{extension}} extension
inverted{{subject}} must not have the {{extension}} extension

Template placeholders

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

Categorization

  • File system

Changelog

VersionDescription
3.0.0Templates changed
1.0.0Created

See Also