laminas/laminas-validator

Digits validator not working because laminas-filter dependency is not listed in `require` section of composer.json

guvra opened this issue · 1 comments

guvra commented

Bug Report

Q A
Version(s) 2.23.0

Summary

The Digits validator uses Laminas\Validator\Digits, as shown here:
https://github.com/laminas/laminas-validator/blob/2.23.0/src/Digits.php#L5

However, the laminas-filter package is not listed in the require section of composer.json.

As a consequence, when this package is installed individually (e.g. with composer require laminas/laminas-validator, the Digits validator throws an exception when used.

Current behavior

The Digits validator throws the following exception:

Class "Laminas\Filter\Digits" not found

How to reproduce

  1. Install the package laminas-validator in a project where laminas-filter is not installed:
composer require laminas/laminas-validator
  1. Run the following sample code:
use Laminas\Validator\Digits;

$validator = new Digits();
$validator->isValid('foo');

Expected behavior

Expected behavior: no exception thrown.

How to fix: this package must include laminas-filter in the require section of composer.json (instead of require-dev).

In the current version of this component, laminas-filter is a soft dependency and therefore listed in the suggest section of the Composer file:

"suggest": {
"laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator",
"laminas/laminas-filter": "Laminas\\Filter component, required by the Digits validator",
"laminas/laminas-i18n": "Laminas\\I18n component to allow translation of validation error messages",
"laminas/laminas-i18n-resources": "Translations of validator messages",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
"laminas/laminas-session": "Laminas\\Session component, ^2.8; required by the Csrf validator",
"laminas/laminas-uri": "Laminas\\Uri component, required by the Uri and Sitemap\\Loc validators",
"psr/http-message": "psr/http-message, required when validating PSR-7 UploadedFileInterface instances via the Upload and UploadFile validators"
},

The additionally required installation is also documented: https://docs.laminas.dev/laminas-validator/validators/digits/