ZF2-337: inArray validator do nothing unless strict is set to true
Description
Unless 'strict' is set to true, the validator just pass the test no matter which data is posted.
Works
$this->add($factory->createInput(array(
'name' => 'activity_type',
'required' => true,
'validators' => array(
array(
'name' => 'InArray',
'options' => array(
'haystack' => array('test', 0, 'A'),
'strict' => true,
),
),
),
)));
Dont works
$this->add($factory->createInput(array(
'name' => 'activity_type',
'required' => true,
'validators' => array(
array(
'name' => 'InArray',
'options' => array(
'haystack' => array('test', 0, 'A'),
),
),
),
)));
Comments
Posted by Maks 3w (maks3w) on 2012-06-25T08:28:56.000+0000
What data are you using?
Posted by Michael Ben-Nes (mbn_18) on 2012-06-25T09:57:34.000+0000
Simple form post
Posted by Maks 3w (maks3w) on 2012-07-12T11:15:11.000+0000
http://php.net/manual/function.in-array.php#104501
Posted by Maks 3w (maks3w) on 2012-07-12T12:30:35.000+0000
Added a check forcing to use strict mode when 0 is present in the haystack
https://github.com/zendframework/zf2/pull/1858