Validate "0" as alphanumeric value (ticket #2972)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5461 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
dho 2007-07-25 14:22:14 +00:00
parent 549d86ac23
commit 7c5b93e34e
2 changed files with 3 additions and 1 deletions

View file

@ -126,7 +126,7 @@ class Validation extends Object {
$this->_extract($check); $this->_extract($check);
} }
if (empty($this->check)) { if (empty($this->check) && $this->check != '0') {
return false; return false;
} }

View file

@ -45,6 +45,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertTrue($this->Validation->alphaNumeric('frferrf')); $this->assertTrue($this->Validation->alphaNumeric('frferrf'));
$this->assertTrue($this->Validation->alphaNumeric('12234')); $this->assertTrue($this->Validation->alphaNumeric('12234'));
$this->assertTrue($this->Validation->alphaNumeric('1w2e2r3t4y')); $this->assertTrue($this->Validation->alphaNumeric('1w2e2r3t4y'));
$this->assertTrue($this->Validation->alphaNumeric('0'));
$this->assertFalse($this->Validation->alphaNumeric('12 234')); $this->assertFalse($this->Validation->alphaNumeric('12 234'));
$this->assertFalse($this->Validation->alphaNumeric('dfd 234')); $this->assertFalse($this->Validation->alphaNumeric('dfd 234'));
$this->assertFalse($this->Validation->alphaNumeric("\n")); $this->assertFalse($this->Validation->alphaNumeric("\n"));
@ -58,6 +59,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertTrue($this->Validation->alphaNumeric(array('check' => 'frferrf'))); $this->assertTrue($this->Validation->alphaNumeric(array('check' => 'frferrf')));
$this->assertTrue($this->Validation->alphaNumeric(array('check' => '12234'))); $this->assertTrue($this->Validation->alphaNumeric(array('check' => '12234')));
$this->assertTrue($this->Validation->alphaNumeric(array('check' => '1w2e2r3t4y'))); $this->assertTrue($this->Validation->alphaNumeric(array('check' => '1w2e2r3t4y')));
$this->assertTrue($this->Validation->alphaNumeric(array('check' => '0')));
$this->assertFalse($this->Validation->alphaNumeric(array('check' => '12 234'))); $this->assertFalse($this->Validation->alphaNumeric(array('check' => '12 234')));
$this->assertFalse($this->Validation->alphaNumeric(array('check' => 'dfd 234'))); $this->assertFalse($this->Validation->alphaNumeric(array('check' => 'dfd 234')));
$this->assertFalse($this->Validation->alphaNumeric(array('check' => "\n"))); $this->assertFalse($this->Validation->alphaNumeric(array('check' => "\n")));