Skip to content

Commit

Permalink
Fix 'Before' and 'After' rules
Browse files Browse the repository at this point in the history
There are 2 small errors in those functions. I think this was caused during the version upgrade that changed the way attributes are parsed.

The original '$date' variable becomes a object so is not possible to parse it as the original string to compare the dates.
  • Loading branch information
Aldo Anizio Lugão Camacho committed Nov 3, 2015
1 parent 572113e commit f66b362
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mako/validator/Validator.php
Expand Up @@ -521,12 +521,12 @@ protected function validateDate($input, $format)

protected function validateBefore($input, $format, $date)
{
if(($date = DateTime::createFromFormat($format, $input)) === false)
if(($input = DateTime::createFromFormat($format, $input)) === false)
{
return false;
}

return ($date->getTimestamp() < DateTime::createFromFormat($format, $date)->getTimestamp());
return ($input->getTimestamp() < DateTime::createFromFormat($format, $date)->getTimestamp());
}

/**
Expand All @@ -541,12 +541,12 @@ protected function validateBefore($input, $format, $date)

protected function validateAfter($input, $format, $date)
{
if(($date = DateTime::createFromFormat($format, $input)) === false)
if(($input = DateTime::createFromFormat($format, $input)) === false)
{
return false;
}

return ($date->getTimestamp() > DateTime::createFromFormat($format, $date)->getTimestamp());
return ($input->getTimestamp() > DateTime::createFromFormat($format, $date)->getTimestamp());
}

/**
Expand Down Expand Up @@ -765,4 +765,4 @@ public function getErrors()
{
return $this->errors;
}
}
}

0 comments on commit f66b362

Please sign in to comment.