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

KeyExists Validator

This validator allows you to validate if a given key is present in an iterable.

Supported Options

The following options are supported for Laminas\Validator\KeyExists:

  • key: Sets the key to be checked. string and int are supported.

Basic Usage

$validator = new Laminas\Validator\KeyExists([
    'key' => 'muppet',
]);

$validInputs = [
    ['muppet' => 'Kermit'],
    new ArrayObject(['muppet' => 'Miss Piggy']),
];

foreach ($validInputs as $input) {
    $result = $validator->isValid($input); // true
}

// Non-exhaustive examples of invalid inputs:
$invalidInputs = [
    'not an array',
    null,
    1,
    'muppet',
];

foreach ($invalidInputs as $input) {
    $result = $validator->isValid($input); // false
}

Integer Keys

PHP casts numeric strings to integers when they are used as array keys:

$array = ['1' => 'Foo'];
// Becomes [1 => 'Foo'];

This validator does the same thing for integer keys:

$validator = new Laminas\Validator\KeyExists([
    'key' => '2',
]);

$validator->isValid(['a', 'b', 'c']); // true

Using a floating point number as a key is not supported because PHP casts floats to integers (And will issue a deprecation on all supported versions of PHP). However, using a string decimal is supported:

$validator = new Laminas\Validator\KeyExists([
    'key' => '1.42',
]);

$validator->isValid(['1.0' => 'a', '1.42' => 'b']); // true

NOTE: Additional Notes Internally the validator calls iterator_to_array on the input to be validated. This may not be desirable if, for example, you are validating a queue where each item is dequeued during iteration, or there are other side effects of iteration on the subject.

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