1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- class sfValidatorDateRange extends sfValidatorBase
- {
-
- protected function configure($options = array(), $messages = array())
- {
- $this->addMessage('invalid', 'The begin date must be before the end date.');
- $this->addRequiredOption('from_date');
- $this->addRequiredOption('to_date');
- }
-
- protected function doClean($value)
- {
- $value['from'] = $this->getOption('from_date')->clean(isset($value['from']) ? $value['from'] : null);
- $value['to'] = $this->getOption('to_date')->clean(isset($value['to']) ? $value['to'] : null);
- if ($value['from'] && $value['to'])
- {
- $v = new sfValidatorSchemaCompare('from', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'to', array('throw_global_error' => true), array('invalid' => $this->getMessage('invalid')));
- $v->clean($value);
- }
- return $value;
- }
- }
|