Back to Validation

Extension

docs/validators/Extension.md

3.1.11.5 KB
Original Source
<!-- SPDX-License-Identifier: MIT SPDX-FileCopyrightText: (c) Respect Project Contributors SPDX-FileContributor: Alexandre Gomes Gaigalas <[email protected]> SPDX-FileContributor: Henrique Moody <[email protected]> -->

Extension

  • Extension(string $extension)

Validates if the file extension matches the expected one:

php
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