particle-php / Validator

Particle\Validator is a validation library with an extremely clean API which makes validation fun!
http://validator.particle-php.com
252 stars 39 forks source link

Fix Container::traverse() method #185

Closed vova07 closed 6 years ago

vova07 commented 6 years ago

What?

This PR fix the bug in Container::traverse() method. We should ensure firstly that we are working with an array before checking for required key.

When?

This is possible use case when we need a validator for nested array, but the input which should be validated contain a non-array value.

// It will throw an exception if we'll provide such input: ['data' => 'someKey'];
// Instead it should fail the validation.
$validator->required('data.someKey')->string(); 

Checklist

Related

The PR which prove the bug: https://github.com/particle-php/Validator/pull/184

vova07 commented 6 years ago

@berry-langerak @RickvdStaaij please review this PR! Thank you for your time!

rick-nu commented 6 years ago

@vova07 Thank you for finding the issue and fixing it! Will merge and release a new patch version! :+1:

rick-nu commented 6 years ago

Released in https://github.com/particle-php/Validator/releases/tag/v2.3.3

Thanks!