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

Laminas Validator provides flexible, reusable validation rules for PHP applications. Includes built-in validators, input filtering/validation chains, and tools for validating common data types like emails, URLs, numbers, strings, and more.

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport