Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Unconventional behavior in EmailAddress validator #41

Open
Saeven opened this issue Sep 17, 2015 · 4 comments
Open

Unconventional behavior in EmailAddress validator #41

Saeven opened this issue Sep 17, 2015 · 4 comments

Comments

@Saeven
Copy link
Contributor

Saeven commented Sep 17, 2015

Configuring a 'message' option on validators should return that single message on failure. (ref http://framework.zend.com/manual/current/en/modules/zend.validator.messages.html)

The second parameter defines the failure which will be overridden. When you omit this parameter, then the given message will be set for all possible failures of this validator.

I have a simple field in a sign up form whose counterpart InputFilter contains this configuration:

'validators' => [
                [
                    'name' => EmailAddress::class,
                    'options' => [
                        'useMxCheck'        => true,
                        'useDeepMxCheck'    => true,
                        'useDomainCheck'    => true,
                        'message'           => _( "Hey bud, check your email." ),
                    ],
                ],

In this case, unfortunately, we get a regex failure that's pretty cryptic on top of what we've set.

The input does not match against pattern '/^[a-zA-Z0-9.!#$%&'+/=?^`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)_$/'

The message configured should preempt the regex failure.

@Maks3w
Copy link
Member

Maks3w commented Sep 17, 2015

Are you using InputFilter? Then message could be defined at the same level of the input and should works too (Except the same message its used for every validator)

@Maks3w
Copy link
Member

Maks3w commented Sep 17, 2015

Also the behavior its supposed to be tested https://github.com/zendframework/zend-validator/blob/master/test/EmailAddressTest.php#L594

Please check again and provide a unit test showing the issue

@Saeven
Copy link
Contributor Author

Saeven commented Sep 17, 2015

Here's a quick repo that exhibits the behavior:
https://github.com/Saeven/validator_test

Can see it from the command line. Email element types are being duplicitous it seems! ;)

@michalbundyra
Copy link
Member

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#45.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants