Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Validation::time so it accepts spaces.

Fixes #2015
  • Loading branch information...
commit 6a05cad69fe1bdce91f9ee4d271cca05ffdb605c 1 parent 07f6803
Mark Story markstory authored
2  cake/libs/validation.php
View
@@ -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();
}
2  cake/tests/cases/libs/validation.test.php
View
@@ -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'));
Please sign in to comment.
Something went wrong with that request. Please try again.