phplibrary/core/validator/rule/time.php
2016-07-14 16:29:26 +03:00

35 lines
746 B
PHP

<?php
require_once 'abstract.php';
/**
* Проверка формата времени
*/
class Rule_Time extends Rule_Abstract
{
private $split = ":";
public function getErrorMsg()
{
return "Неверный формат времени";
}
static function checktime($hour, $minute)
{
if ($hour > -1 && $hour < 24 && $minute > -1 && $minute < 60) {
return true;
}
}
public function isValid(Collection $container, $status = null)
{
$tmp = explode($this->split, $container->get($this->field), 2);
if ($tmp) {
if (self::checktime ($tmp[0], $tmp[1])) {
return true;
}
}
return false;
}
}