nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

Validator does not accept Nette\DI\DynamicParameter #243

Closed patrickkusebauch closed 3 years ago

patrickkusebauch commented 3 years ago

Version: v3.1.4

Bug Description

When a Nette extension validates it's input parameters via Nette Validator, you cannot use Nette Dynamic parameters.

Steps To Reproduce

  1. Install kdyby/rabbitmq
  2. set up config.neon like this:
    
    parameters:
    messageQueue:
        host: %env.MESSAGE_QUEUE_HOST%
        user: %env.MESSAGE_QUEUE_USER%
        password: %env.MESSAGE_QUEUE_PASSWORD%
        db: %env.MESSAGE_QUEUE_DB%

rabbitmq: connection: host: %messageQueue.host% port: 5672 user: %messageQueue.user% password: %messageQueue.password% vhost: %messageQueue.db%

3. and Booting.php like this:
```php
        $configurator->addDynamicParameters([
            'env' => getenv(),
        ]);

Expected Behavior

The value of the dynamic parameter is passed, not the reference to it.

Possible Solution

Typecasting in the configuration file

dg commented 3 years ago

It must be fixed in kdyby/rabbitmq. Like Validators::assertField($config, 'user', 'string|Nette\DI\DynamicParameter')