phplibrary/src/Validator/Rule/Notnull.php
2018-04-13 17:59:57 +03:00

31 lines
686 B
PHP

<?php
namespace ctiso\Validator\Rule;
use ctiso\Validator\Rule\AbstractRule,
ctiso\Collection;
class Notnull extends AbstractRule
{
function skipEmpty() {
return false;
}
public function getErrorMsg()
{
return "Поле не должно быть пустым";
}
public function isValid(Collection $container, $status = null)
{
$data = $container->get($this->field);
if (is_array($data)) {
foreach($data as $c) {
if (trim($c) != '') return true;
}
return false;
} else {
$value = trim($data);
return $value != '';
}
}
}