Skip to content
Permalink
Browse files

Fix Validation::multiple() regarding 0 value.

  • Loading branch information...
dereuromark committed Jun 15, 2015
1 parent 0b20f6d commit 86c358f3f901814ceb1b3d62c30b4ad422e14291
Showing with 10 additions and 8 deletions.
  1. +8 −6 lib/Cake/Test/Case/Utility/ValidationTest.php
  2. +2 −2 lib/Cake/Utility/Validation.php
@@ -2085,17 +2085,19 @@ public function testMultiple() {
$this->assertFalse(Validation::multiple(''));
$this->assertFalse(Validation::multiple(null));
$this->assertFalse(Validation::multiple(array()));
$this->assertFalse(Validation::multiple(array(0)));
$this->assertFalse(Validation::multiple(array('0')));
$this->assertTrue(Validation::multiple(array(0)));
$this->assertTrue(Validation::multiple(array('0')));
$this->assertFalse(Validation::multiple(array('')));
$this->assertTrue(Validation::multiple(array(0, 3, 4, 5), array('in' => range(0, 10))));
$this->assertFalse(Validation::multiple(array(0, 15, 20, 5), array('in' => range(0, 10))));
$this->assertFalse(Validation::multiple(array(0, 5, 10, 11), array('in' => range(0, 10))));
$this->assertFalse(Validation::multiple(array('boo', 'foo', 'bar'), array('in' => array('foo', 'bar', 'baz'))));
$this->assertFalse(Validation::multiple(array('foo', '1bar'), array('in' => range(0, 10))));
$this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('max' => 3)));
$this->assertFalse(Validation::multiple(array(0, 5, 10, 11, 55), array('max' => 3)));
$this->assertFalse(Validation::multiple(array(1, 5, 10, 11), array('max' => 3)));
$this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('max' => 4)));
$this->assertFalse(Validation::multiple(array(0, 5, 10, 11, 55), array('max' => 4)));
$this->assertTrue(Validation::multiple(array('foo', 'bar', 'baz'), array('max' => 3)));
$this->assertFalse(Validation::multiple(array('foo', 'bar', 'baz', 'squirrel'), array('max' => 3)));
@@ -2110,8 +2112,8 @@ public function testMultiple() {
$this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5)));
$this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5)));
$this->assertFalse(Validation::multiple(array(0, 5, 9), array('in' => range(0, 10), 'max' => 5, 'min' => 3)));
$this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5, 'min' => 2)));
$this->assertFalse(Validation::multiple(array(-1, 5, 9), array('in' => range(0, 10), 'max' => 5, 'min' => 3)));
$this->assertFalse(Validation::multiple(array(-1, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5, 'min' => 2)));
$this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5, 'min' => 2)));
$this->assertFalse(Validation::multiple(array('2x', '3x'), array('in' => array(1, 2, 3, 4, 5))));
@@ -143,7 +143,7 @@ public static function blank($check) {
* Returns true if $check is in the proper credit card format.
*
* @param string|array $check credit card number to validate
* @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit
* @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit
* cards
* if an array is used only the values of the array are checked.
* Example: array('amex', 'bankcard', 'maestro')
@@ -594,7 +594,7 @@ public static function multiple($check, $options = array(), $caseInsensitive = f
$defaults = array('in' => null, 'max' => null, 'min' => null);
$options += $defaults;
$check = array_filter((array)$check);
$check = array_filter((array)$check, 'strlen');
if (empty($check)) {
return false;
}

0 comments on commit 86c358f

Please sign in to comment.
You can’t perform that action at this time.