Skip to content

Commit

Permalink
Fix construction of sfValidatorError with an array of an array
Browse files Browse the repository at this point in the history
So in error messages the use of %year% %month% and %day% becomes possible
  • Loading branch information
Florian Hoss authored and thePanz committed Jan 19, 2024
1 parent 6354fd3 commit 8962c0c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/validator/sfValidatorDate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function convertDateArrayToString($value)
// all elements must be empty or a number
foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) {
if (isset($value[$key]) && !ctype_digit((string) $value[$key]) && !empty($value[$key])) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}
}

Expand All @@ -164,14 +164,14 @@ protected function convertDateArrayToString($value)
(!isset($value['month']) || !$value['month'] ? 1 : 0) +
(!isset($value['day']) || !$value['day'] ? 1 : 0);
if ($empties > 0 && $empties < 3) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}
if (3 == $empties) {
return $this->getEmptyValue();
}

if (!checkdate((int) $value['month'], (int) $value['day'], (int) $value['year'])) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}

if ($this->getOption('with_time')) {
Expand All @@ -181,7 +181,7 @@ protected function convertDateArrayToString($value)
$this->isValueSet($value, 'second') && (!$this->isValueSet($value, 'minute') || !$this->isValueSet($value, 'hour'))
|| $this->isValueSet($value, 'minute') && !$this->isValueSet($value, 'hour')
) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}

$clean = sprintf(
Expand Down

0 comments on commit 8962c0c

Please sign in to comment.