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

Explode Validator

Laminas\Validator\Explode executes a validator for each item exploded from an array.

Supported Options

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

  • valueDelimiter: Defines the delimiter used to explode values from an array. It defaults to ,.
  • validator: Sets the validator that will be executed on each exploded item. This may be a validator instance, a validator service name, or a "specification" array.
  • validatorPluginManager: The validator plugin manager in use in your application. If this plugin manager is not provided, a plugin manager will be created with the default configuration.

Basic Usage

To validate if every item in an array is in a specified haystack:

$inArrayValidator = new Laminas\Validator\InArray([
    'haystack' => [1, 2, 3, 4, 5, 6],
]);

$explodeValidator = new Laminas\Validator\Explode([
    'validator' => $inArrayValidator
]);

$explodeValidator->isValid('1,4,6');    // returns true
$explodeValidator->isValid('1,4,6,8'); // returns false

Configuration Using a Validator Specification

Instead of creating a validator instance, you can provide an array to describe the validator you wish to use for each element:

$explodeValidator = new Laminas\Validator\Explode([
    'validator' => [
        'name' => Laminas\Validator\InArray::class,
        'options' => [
            'haystack' => ['a', 'b', 'c']
        ],
    ],
    'valueDelimiter' => ';',
]);

$explodeValidator->isValid('a;b'); // returns true
$explodeValidator->isValid('x;y;z');  // returns false

About the $context Parameter

The isValid implementation in Explode accepts a second argument ?array $context = null.

This argument when used via laminas-inputfilter will contain the entire payload, typically $_POST.

The context is passed to the composed item validator that checks each element in the given value in case that composed validator needs access to the wider validation context to perform conditional validation.

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
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
twbs/bootstrap4