You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Zend\Validator\Regex::__construct(), 0 passed in <REDACTED>/vendor/zendframework/zend-servicemanager/src/Factory/InvokableFactory.php on line 30 and exactly 1 expected in <REDACTED>/vendor/zendframework/zend-validator/src/Regex.php:51
Stack trace:
#0 <REDACTED>/vendor/zendframework/zend-servicemanager/src/Factory/InvokableFactory.php(30): Zend\Validator\Regex->__construct()
#1 <REDACTED>/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(758): Zend\ServiceManager\Factory\InvokableFactory->__invoke(Object(Zend\ServiceManager\ServiceManager), 'Zend\\Validator\\...', NULL)
#2 <REDACTED>/vendor/zendframework/zend-servicemanager/src/Servic in <REDACTED>/vendor/zendframework/zend-validator/src/Regex.php on line 51
Both the approaches of passing options to the ValidatorPluginManager and configuring the validator after invocation work fine for all validators except Regex. From what I can tell, the Regex validator is the only one in the zendframework/zend-validator package where the constructor parameter is mandatory:
For all the other validators the contructor parameters are optional, which is exactly how the AbstractValidator describes it:
/** * Abstract constructor for all validators * A validator should accept following parameters: * - nothing f.e. Validator() * - one or multiple scalar values f.e. Validator($first, $second, $third) * - an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third')) * - an instance of Traversable f.e. Validator($config_instance) * * @param array|Traversable $options */publicfunction__construct($options = null)
{
// ...
}
Everything works fine using the first approach above, and it may be a deliberate design decision for the Regex contructor parameter to be mandatory, but it appeared out of place to me so I thought it worth mentioning in case this was an oversight.
I can obtain a
Regex
validator from theValidatorPluginManager
like so:However, if I attempt to obtain a
Regex
validator without the options (to configure it later) I received a PHP Fatal error:Both the approaches of passing options to the
ValidatorPluginManager
and configuring the validator after invocation work fine for all validators exceptRegex
. From what I can tell, theRegex
validator is the only one in thezendframework/zend-validator
package where the constructor parameter is mandatory:For all the other validators the contructor parameters are optional, which is exactly how the
AbstractValidator
describes it:Everything works fine using the first approach above, and it may be a deliberate design decision for the
Regex
contructor parameter to be mandatory, but it appeared out of place to me so I thought it worth mentioning in case this was an oversight.Originally posted by @mrobinsonuk at zendframework/zend-validator#200
The text was updated successfully, but these errors were encountered: