File

February 3, 2026 · View on GitHub

  • File()

Validates whether file input is as a regular filename.

v::file()->assert(__FILE__);
// Validation passes successfully

v::file()->assert(__DIR__);
// → "/path/to/dir" must be an accessible existing file

This validator will consider SplFileInfo instances, so you can do something like:

v::file()->assert(new SplFileInfo('/path/to/file.txt'));
// Validation passes successfully

Templates

File::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be an accessible existing file
inverted{{subject}} must not be an accessible existing file

Template placeholders

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

Categorization

  • File system

Changelog

VersionDescription
3.0.0Templates changed
0.5.0Created

See Also