Avoid integer and float values false pass 'inList' validation #801

wants to merge 7 commits into


None yet
4 participants

v-v-vishnevskiy commented Jan 25, 2013

As PHP prefers to compare integers/floats if one of the arguments have type int/float false positives are very common, like 0 == 'a'. This patch prevents such behavior for 'inList' validation rule but only for case when validated value have type int/float. It does not process list of allowed values.


jails commented Jan 25, 2013

Thanks for the effort on this issue. However this issue seems to be "unfixable". Indeed this PR only brings the following inconsitency:

$this->assertFalse(Validator::isInList(0, null, array('list' => array('a')))); //pass
$this->assertTrue(Validator::isInList('a', null, array('list' => array(0)))); //also pass

Imo we can't do more than #737 and left the casting managment to the developer.


v-v-vishnevskiy commented Jan 28, 2013

I see. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment