Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Validator Laravel Package

laminas/laminas-validator

Validation component for PHP and Laminas applications. Provides a wide range of ready-to-use validators (strings, numbers, dates, files, and more), consistent error messages, and an extensible API to create custom validators and input filtering rules.

View on GitHub
Deep Wiki
Context7

Exists

Laminas\Validator\File\Exists checks for the existence of files in specified directories.

This validator is inversely related to the NotExists validator.

Supported Options

The following set of options are supported:

  • directory: Array of directories, or comma-delimited string of directories.
  • all: A boolean that when true (default) requires that the filename is present in all the listed directories

Usage Examples

use Laminas\Validator\File\Exists;

// Only allow files that exist in ~both~ directories
$validator = new Exists(['directory' => '/tmp,/var/tmp']);

if ($validator->isValid('myfile.txt')) {
    // file is present in all directories
} else {
    // file was not present in at least 1 of the directories
}
use Laminas\Validator\File\Exists;

// Allow files that exist in any of the listed directories
$validator = new Exists([
    'directory' => ['/tmp', '/var/tmp'],
    'all' => false,
]);

if ($validator->isValid('myfile.txt')) {
    // file was found in at least 1 directory
} else {
    // file was not found in one of the directories
}
use Laminas\Validator\File\Exists;

// Check the value for existence without a directory option
$validator = new Exists();

if ($validator->isValid('/path/to/myfile.txt')) {
    // file exists
}

Checks against All Directories

By default, this validator checks whether the specified file exists in all of the given directories; validation will fail if the file does not exist in one or more of them. To change this behaviour, be sure to set the all option to false.

Validating Uploaded Files

This validator accepts and validates 3 types of argument:

  • A string that represents a path or a file name
  • An array that represents an uploaded file as per PHP's $_FILES superglobal
  • A PSR-7 UploadedFileInterface instance

Without a directory option, the validator will check any of the listed argument types to ensure they exist. For example, without a directory option, any successful upload will be deemed valid.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai