I using Phalcon framework, i have a Collection Model, in validate()
function of this model, i validate my fields like below:
class Users extends Collection
{
public function validation()
{
$this->validate(
new EmailValidator(
array(
"field" => "email",
"message" => "email is not valid"
)
)
);
$this->validate(
new NumericalityValidator(
array(
"field" => "phone",
"message" => "phone is not valid"
)
)
);
return $this->validationHasFailed() != true;
}
}
How can i tel to this model one of these two fields are mandatory ? for example if tel is not empty, email can be empty, or if email is not empty, tel can empty, and when both fields are empty, validation should be failed.