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

Date Validator

Laminas\Validator\Date allows you to validate if a given value contains a date.

Supported Options

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

  • format: Sets the format which is used to write the date.
  • strict: Ensures that string input exactly matches the generated date when formatted

Default Date Validation

The easiest way to validate a date is by using the default date format, Y-m-d.

$validator = new Laminas\Validator\Date();

$validator->isValid('2000-10-10');   // returns true
$validator->isValid('10.10.2000'); // returns false

Specifying a Date Format

Laminas\Validator\Date also supports custom date formats. When you want to validate such a date, use the format option. This option accepts any format allowed by the PHP DateTime::createFromFormat() method.

$validator = new Laminas\Validator\Date(['format' => 'Y']);

$validator->isValid('2010'); // returns true
$validator->isValid('May');  // returns false

Strict Mode

By default, Laminas\Validator\Date only validates that it can convert the provided value to a valid DateTime value.

If you want to require that the date is specified in a specific format, you can provide both the date format and the strict options. In such a scenario, the value must both be convertable to a DateTime value and be in the same format as provided to the validator. (Generally, this will mean the value must be a string.)

$validator = new Laminas\Validator\Date(['format' => 'Y-m-d', 'strict' => true]);

$validator->isValid('2010-10-10'); // returns true
$validator->isValid(new DateTime('2010-10-10')); // returns false; value is not a string
$validator->isValid('2010.10.10'); // returns false; format differs
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