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

Symfony Validation Shorthand Laravel Package

digitalrevolution/symfony-validation-shorthand

View on GitHub
Deep Wiki
Context7
Index
Shorthands
Array data Validation
Traversable data validation
Examples

Traversable data validation

Symfony's All Constraint allows you to validate \Traversable data. For example data read from a csv or Excel provided via a yield function. The * notation marks the set as iterable and internally the All constraint will be used instead of Collection.

ArrayIterator example

Rules:
For a csv with 4 columns.

[
    '*.0' => 'required|int|min:1',
    '*.1' => 'required|string|email',
    '*.2' => 'required|float',
    '*.3' => 'required|string|max:2000'
]

Validates:

$iterator = new ArrayIterator(
    [
        ['4', '[email protected]', '2.59', 'apples'],
        ['9', '[email protected]', '3.06', 'raspberries'],
        ['3', '[email protected]', '115.99', 'pineapple'],
    ]   
);

Non empty value set

By default the * will allow the set to be empty. If you validate a set of values, you can mark the set as non-empty with the required rule.

Rules:

['*' => 'required|int']

Validates:

success: [1, 2, '3']
fails:   []
fails:   [1, 'a']
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.
mydnic/volet-feature-board
wmde/fundraising-phpcs
friendlylabs/surveyr
mg-techlegend/laravel-notify-africa
islamabdurahman/laravel-sms-service
dmhendricks/b2-sdk-php
aplicativa/laravel-admin
ezavalishin/vkma
jackardios/laravel-json-api-paginate
viral/laravel-adminpanel
dieppk/log-viewer
daimakuai-ext/helpers
codexshaper/php-blade-view
abraxas81/charts
adamlien/laravel-cas
quimgc/tasks
sistem-atc/bank-sdk
core45/laravel-cookieconsent
projectsend/community-modules
ovac/laravel-hubtel-payment