Digits validator not working because laminas-filter dependency is not listed in `require` section of composer.json
guvra opened this issue · 1 comments
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
- Install the package laminas-validator in a project where laminas-filter is not installed:
composer require laminas/laminas-validator
- 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:
laminas-validator/composer.json
Lines 54 to 63 in 3ebb924
The additionally required installation is also documented: https://docs.laminas.dev/laminas-validator/validators/digits/