Weave 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

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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log