31 lines
705 B
PHP
31 lines
705 B
PHP
<?php
|
|
|
|
namespace ctiso\Validator\Rule;
|
|
use ctiso\Validator\Rule\AbstractRule,
|
|
ctiso\Collection;
|
|
|
|
class Notnull extends AbstractRule
|
|
{
|
|
function skipEmpty(): bool {
|
|
return false;
|
|
}
|
|
|
|
public function getErrorMsg(): string
|
|
{
|
|
return "Поле не должно быть пустым";
|
|
}
|
|
|
|
public function isValid(Collection $container, $status = null): bool
|
|
{
|
|
$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 != '';
|
|
}
|
|
}
|
|
}
|