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

NotExists

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

This validator is inversely related to the Exists validator.

Supported Options

The following set of options are supported:

  • directory: Array of directories or comma-delimited string of directories against which to validate.

Basic Usage

use Laminas\Validator\File\NotExists;

// Only allow files that do not exist in any of the given directories
$validator = new NotExists([
    'directory' => ['/tmp', '/var/tmp'],
]);

if ($validator->isValid('some-file.txt')) {
    // File cannot be found in any of the directories provided
} else {
    // A file with the given name was found
}

Checks against All Directories

This validator checks whether the specified file does not exist in any of the given directories; validation will fail if the file exists in one (or more) of the given directories.

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

When provided with either a PSR-7 Uploaded File, or a normalised $_FILES upload, if the directory option is unset, validation will fail for successfully uploaded files, however, when a directory option is provided, the given directories are searched for the base name of the uploaded file path.

In the following example, assume $files is an array that represents a single, successful file upload in PHP's $_FILES array format.

use Laminas\Validator\File\NotExists;

$validator = new NotExists();
$validator->isValid($files); // False - the uploaded file exists (Of course)

$validator = new NotExists([
    'directory' => [
        '/home/files',
        '/tmp',
    ],
]);

if ($validator->isValid($files)) {
    // The basename of the uploaded file could not be found in any of the directories
} else {
    // The basename of the uploaded file was located in at least 1 of the directories
}
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