Vegas CMF Validation


You can use SizeOf validator with Cloneable, MutliSelect or any other form element that have countable fields. Validator will count non-empty fields and compare them to numbers given by min and max options.


namespace Foo\Forms;

use Phalcon\Forms\Element\Text;
use Vegas\Validation\Validator\PresenceOf;
use Vegas\Validation\Validator\SizeOf;

class Bar extends \Vegas\Forms\Form
    public function initialize()
        $names = new Cloneable('names');
        $names->setLabel($this->i18n->_('List of names'));
        $names->setBaseElements(new Text('name'));
        $names->addValidator(new SizeOf([
            'min' => 2,
            'max' => 6


        // ...