Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unconventional behavior in EmailAddress validator #45

Closed
michalbundyra opened this issue Jan 15, 2020 · 3 comments
Closed

Unconventional behavior in EmailAddress validator #45

michalbundyra opened this issue Jan 15, 2020 · 3 comments
Assignees
Labels
Won't Fix This will not be worked on

Comments

@michalbundyra
Copy link
Member

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.


Originally posted by @Saeven at zendframework/zend-validator#41

@michalbundyra
Copy link
Member Author

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)


Originally posted by @Maks3w at zendframework/zend-validator#41 (comment)

@michalbundyra
Copy link
Member Author

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


Originally posted by @Maks3w at zendframework/zend-validator#41 (comment)

@michalbundyra
Copy link
Member Author

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! ;)


Originally posted by @Saeven at zendframework/zend-validator#41 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't Fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants