I've found that the new way of using validation in models has not been extended to collections.
Collections still currently use Phalcon\Mvc\Model\Validator's.
If Model Validators are to be deprecated then this should be possible with Collections:
public function validation()
{
$validator = new Validation();
$validator->add(
'email', //your field name
new EmailValidator([
'collection' => $this,
'message' => 'Please enter a correct email address'
])
);
$validator->add(
'username',
new UniquenessValidator([
'collection' => $this,
'message' => 'Sorry, That username is already taken',
])
);
return $this->validate($validator);
}
Are there any plans to do this or is support to Collections going to cease to be?