Регистр файлов
This commit is contained in:
parent
4fd0187ea6
commit
c8958cbee0
83 changed files with 25 additions and 53 deletions
32
src/Validator/Rule/Count.php
Normal file
32
src/Validator/Rule/Count.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Проверка формата даты
|
||||
*/
|
||||
class Validator_Rule_Count extends Rule_Abstract
|
||||
{
|
||||
public $size = 1;
|
||||
public $max = false;
|
||||
|
||||
public function getErrorMsg()
|
||||
{
|
||||
return "Количество записей должно быть не менне {$this->size} и не более {$this->max}";
|
||||
}
|
||||
|
||||
function not_empty($s) {
|
||||
return $s != "";
|
||||
}
|
||||
|
||||
public function isValid(Collection $container, $status = null)
|
||||
{
|
||||
|
||||
if (!$this->max) {
|
||||
$this->max = $this->size;
|
||||
}
|
||||
$count = count(array_filter(array_map('trim',
|
||||
explode(";", $container->get($this->field))), array($this, 'not_empty')));
|
||||
|
||||
return $count >= $this->size && $count <= $this->max;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue