Hello everyone. I am trying to implement a custom validator in Phalcon to check if a date is of a correct format but also to check if the day actually existed (for example I am not allowing the 30th of Feb). But I am kind of stuck. I need this validator to validate a form field. Which methods should I implement to make it work as a usual Phalcon validator (it has to display a message passed, cancel other validators to validate if it fails and so on). This is what I currently have
<?php
use Phalcon\Validation\Validator,
Phalcon\Validation\ValidatorInterface,
Phalcon\Validation\Message;
class DateValidator extends Validator implements ValidatorInterface
{
public function __construct($options = null)
{
parent::__construct();
if ($options != null)
{
$this->_options = $options;
}
}
/**
* Executes the validation
*
* @param Phalcon\Validation $validator
* @param string $attribute
* @return boolean
*/
public function validate($validator, $attribute)
{
}
}
This was mostly copied from here. I don't quite understand how the the validate method has to work, what are these params ($validator, $attribute) for ? Which methods should I also impement to make it work as a normal phalcon validator. Thanks in advance.