use Zend\InputFilter\InputFilter;
use Zend\Filter\StringTrim;
use Zend\Filter\StripTags;
use Zend\InputFilter\Input;
use Zend\Validator\EmailAddress;
use Zend\Validator\NotEmpty;
class MyInputFilter extends InputFilter
{
public function __construct()
{
$email = new Input('email');
$email->setRequired(true);
$email->getFilterChain()
->attach(new StringTrim())
->attach(new StripTags());
$email->getValidatorChain()
->attach(new EmailAddress())
->attach(new NotEmpty());
$this->add($email);
$name = new Input('name');
$name->setRequired(true);
$name->getFilterChain()
->attach(new StringTrim())
->attach(new StripTags());
$name->getValidatorChain()
->attach(new NotEmpty());
$this->add($name);
}
}
bool(false)
array(2) {
[0]=>
array(1) {
["email"]=>
array(1) {
["isEmpty"]=>
string(36) "Value is required and can't be empty" // which is fine here
}
}
[1]=>
array(1) {
["email"]=>
array(1) {
["isEmpty"]=>
string(36) "Value is required and can't be empty" // which is not fine
}
}
}
second's element email message should be
array(3) {
["emailAddressInvalidHostname"]=>
string(53) "'tom' is not a valid hostname for the email address"
["hostnameInvalidHostname"]=>
string(66) "The input does not match the expected structure for a DNS hostname"
["hostnameLocalNameNotAllowed"]=>
string(84) "The input appears to be a local network name but local network names are not allowed"
}
Let's say I have an InputFilter
and the logic that goes
I get
second's element email message should be
looks like a bug.