Skip to content

Commit

Permalink
Fix Validation::time so it accepts spaces.
Browse files Browse the repository at this point in the history
Fixes #2015
  • Loading branch information
markstory committed Sep 23, 2011
1 parent 07f6803 commit 6a05cad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/validation.php
Expand Up @@ -429,7 +429,7 @@ function time($check) {
$_this =& Validation::getInstance();
$_this->__reset();
$_this->check = $check;
$_this->regex = '%^((0?[1-9]|1[012])(:[0-5]\d){0,2}([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%';
$_this->regex = '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%';
return $_this->_check();
}

Expand Down
2 changes: 2 additions & 0 deletions cake/tests/cases/libs/validation.test.php
Expand Up @@ -1509,6 +1509,8 @@ function testTime() {
$this->assertTrue(Validation::time('12:01am'));
$this->assertTrue(Validation::time('12:01pm'));
$this->assertTrue(Validation::time('1pm'));
$this->assertTrue(Validation::time('1 pm'));
$this->assertTrue(Validation::time('1 PM'));
$this->assertTrue(Validation::time('01:00'));
$this->assertFalse(Validation::time('1:00'));
$this->assertTrue(Validation::time('1:00pm'));
Expand Down

0 comments on commit 6a05cad

Please sign in to comment.