Good night, why is this custom validator is not workink, it calls the function validate($validator, $attribute) return false, but the form isValid() still return true
I have to register in any place?
Thanks Good Night code below
Code at paste bin : https://pastebin.com/vPY69afH
......
use Phalcon\Validation\Validator, Phalcon\Validation\ValidatorInterface, Phalcon\Validation\Message;
class DbNoRecordExists extends Validator implements ValidatorInterface { public function validate($validator, $attribute) { $valid = ( $find->count() ) ? false : true; return $valid; } }
$slug = new Text("slug");
$slug->addValidator(new DbNoRecordExists(array( 'db' => 'paginas', 'message' => 'Slug já cadastrado', )));
$slug->addValidator(new PresenceOf(array( 'message' => 'The slug is required' )));
$slug->addValidator(new StringLength(array( 'min' => 3, 'messageMinimum' => 'The slug is too short' )));
$this->add($slug);