Hi, I've created my own validator for some models - see below. After updating to Phalcon 2 the framework throws always an error, that the validator is not defined as expected: Fatal error: Declaration of SlipBOX\Libraries\Models\ValidatorMin::validate() must be compatible with Phalcon\Mvc\Model\ValidatorInterface::validate(Phalcon\Mvc\ModelInterface $record) in
I hope you can help me. The code for the validator is almost copied from the documentations. I delevop now without that validator, but would be nice to have it back. :) Thanks a lot (again and again and again) Aljoscha
<?php
namespace SlipBOX\Libraries\Models;
use Phalcon\Mvc\Model\Validator,
Phalcon\Mvc\Model\ValidatorInterface;
class ValidatorMin extends Validator implements ValidatorInterface
{
/**
* Executes the validation
* @param Phalcon\Validation $validator
* @param string $attribute
* @return boolean
*/
public function validate ($record)
{
$field = $this->getOption('field');
$min = $this->getOption('min');
$value = $record->$field;
if ($value < $min) {
$message = $this->getOption('message');
if (!$message) {
$message = "The field's value is smaller than allowed.";
}
$this->appendMessage(
$message,
$field,
"ValidatorMin"
);
return false;
}
return true;
}
}