Skip to content

Commit

Permalink
localizedTime()
Browse files Browse the repository at this point in the history
Proxy method for new Validation::localizedTime()
  • Loading branch information
ypnos-web committed Feb 24, 2016
1 parent 31c21bf commit 067f2b4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Validation/Validator.php
Expand Up @@ -824,6 +824,26 @@ public function time($field, $message = null, $when = null)
]);
}

/**
* Add a localized time, date or datetime format validation rule to a field.
*
* @param string $field The field you want to apply the rule to.
* @param string $type Parser type, one out of 'date', 'time', and 'datetime'
* @param string|int $format any format accepted by IntlDateFormatter
* @param string $message The error message when the rule fails.
* @param string|callable $when Either 'create' or 'update' or a callable that returns
* true when the valdiation rule should be applied.
* @see \Cake\Validation\Validation::localizedTime()
* @return $this
*/
public function localizedTime($field, $type = 'datetime', $format = null, $message = null, $when = null)
{
$extra = array_filter(['on' => $when, 'message' => $message]);
return $this->add($field, $type, $extra + [
'rule' => ['localizedTime', $type, $format]
]);
}

/**
* Add a boolean validation rule to a field.
*
Expand Down

0 comments on commit 067f2b4

Please sign in to comment.