There is a code validations enter e-mail address:
class emailTemplateFormValidation extends Validation
{
public function initialize()
{
$this->add('assignedEmail', new Email(array(
'message' => 'Неверный e-mail адрес',
)));
}
}
...................
$messages = $emailTemplateFormValidation->validate($cleanedPostData);
if (count($messages)) {
foreach ($messages as $message) {
$message = $message.'<br>';
}
$this->flashSession->error($message);
}
it is expected that it works like this:
- if a valid e-mail ("[email protected]"), then the validation passes;
- if you entered an incorrect e-mail ("[email protected]"), then the validation fails;
- if you enter an empty string (""), then the validation passes.
in fact: when entering an empty string ("") - validation does not pass.
I need: if the field is empty (""), then the validation passes successfully