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

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', 'exampleA@example.com', '2.59', 'apples'],
        ['9', 'exampleB@example.com', '3.06', 'raspberries'],
        ['3', 'exampleC@example.com', '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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
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