I just write something like this:
use Phalcon\Validation\Validator\Between;
class Users extends \Phalcon\Mvc\Model {
public function validation() {
$this->validate(new Between(array(
'minimum' => 3,
'maximum' => 21,
'field' => 'nickname',
'message' => 'reg_error_nick_len'
)));
}
}
And when I try to save model I have this exception trace (uniquness and email work normal):
Unexpected value type: expected object implementing Phalcon\Mvc\Model\ValidatorInterface, object of type Phalcon\Validation\Validator\Between given
\#0 W:\domains\ely.by\app\models\Users.php(60): Phalcon\Mvc\Model->validate(Object(Phalcon\Validation\Validator\Between))
\#1 [internal function]: Users->validation()
\#2 [internal function]: Phalcon\Mvc\Model->fireEventCancel('validation')
\#3 [internal function]: Phalcon\Mvc\Model->_preSave(Object(Phalcon\Mvc\Model\MetaData\Memory), true, 'id')
\#4 W:\domains\ely.by\app\controllers\AuthorizationController.php(88): Phalcon\Mvc\Model->save(Array, Array)
\#5 [internal function]: AuthorizationController->finishAction()
\#6 [internal function]: Phalcon\Dispatcher->dispatch()
\#7 W:\domains\ely.by\public\index.php(32): Phalcon\Mvc\Application->handle()
\#8 {main}