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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle