Ticket #852 (closed defect: fixed)
Validators for 'time' and 'timestamp' fields do not exist
| Reported by: | mark.pearson | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.10.4 |
| Component: | Other | Version: | 0.10.0 |
| Severity: | Keywords: | Validators time timestamp | |
| Cc: | Has Test: | ||
| Status: | Has Patch: |
Description
The Doctrine manual specifies in sections 3.4.4.11 and 3.4.4.12 that 'timestamp' and 'time' field types are available. However, turning on validation with Doctrine::VALIDATE_ALL highlights some problems with validation of these field types.
The class below is used as a testbed to reproduce these problems:
class DateTimeTest extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('theTime', 'time', null, array('notnull'));
$this->hasColumn('theTimestamp', 'timestamp', null, array('notnull'));
}
public function setUp() {
}
}
Running the following script:
require_once('...Doctrine/lib/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
$db = Doctrine_Manager::connection('mysql://....');
Doctrine::loadModels('models/types'); // This is where DateTimeTest.php lives
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$dtt = new DateTimeTest;
$dtt->theTime = '12:34:56';
$dtt->theTimestamp = 'This is not a timestamp';
if (!$dtt->isValid()) {
print_r($dtt->getErrorStack());
}
produces the following (incorrect output)
Doctrine_Validator_ErrorStack Object
(
[errors:protected] => Array
(
[theTime] => Array
(
[0] => type
)
)
[classname:protected] => DateTimeTest
[_locator:protected] =>
[_resources:protected] => Array
(
)
)
The 'time' field has a valid value according to the manual but fails validation whilst the 'timestamp' field has an invalid value but passes.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.