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

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.
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