Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null values using a Juicer #11

Open
rgazelot opened this issue Mar 20, 2018 · 0 comments
Open

Handle null values using a Juicer #11

rgazelot opened this issue Mar 20, 2018 · 0 comments
Labels

Comments

@rgazelot
Copy link

rgazelot commented Mar 20, 2018

Hi there, it's me again!

I found a weird case to handle : I wanted to use a Juicer on a field and when I wrote tests I tried with a null value and found that it throws a php exception about the clean process.

$validator
  ->addField('foo', true)
    ->addJuicer('foo', (new \Chanmix51\ParameterJuicer\ParameterJuicer)
        ->addField('bar', true)
          ->addValidator('bar', function($v) {
            if ("baz" !== $v) {
              throw new \Chanmix51\ParameterJuicer\ValidationException('error.');
            }
          })
    )
;

$data = [
  'foo' => null,
];

$data = $validator->squash($data);

// PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Chanmix51\ParameterJuicer\ParameterJuicer::clean() must be of the type array, null given in /vendor/chanmix51/parameter-juicer/sources/lib/ParameterJuicer.php:348

I think that this case should be handle, what do you think?

@chanmix51 chanmix51 added the bug label Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants