Zend\Validator depends on Zend\Filter #4778

wants to merge 1 commit into

3 participants


This is not in it's composer.json

Zend Framework member

Actually, only Zend\Validator\Digits does, which means it is at best an optional ("suggest", in composer) dependency.


I think had the error and all I was using 'Alnum' validator.

Zend Framework member

Alnum is part of Zend\I18n which has Zend\Filter as a suggest in its composer.json: https://github.com/zendframework/zf2/blob/master/library/Zend/I18n/composer.json#L22


Well I have another ticket open because the documentation is wrong & incorrectly says that Alnum is part of Zend\Validator.

But hear me out here. I think this is too hard for the users to install & use. As a user I simply want to require a single package "Zend\Validator" and then start validating data. Currently that is not possible, if I want to validate something is alpha numeric I have to require Zend\Validator, Zend\Filter, and Zend\I18n. I don't feel like that's how composers supposed to work. I feel like its supposed to work like this. I just require Zend\Validator, and I can start validating data.

I feel like there should be a Zend\Validator\Alnum. It would validate [a-zA-Z0-9] with no support for foreign characters, and would suggest I18n for supporting special characters.

But currently its not that simple. Even if all I care about is simple characters, I have to read through log output of composer to see all these package "suggestions" which actually are requirements. You're forcing me to be cognitively figure out the dependencies instead of letting composer do it. Sure, maybe some validators work without I18n or Filter, but you're severely limiting me. Alnum is a basic functionality & should work out of the box, I feel.


Let me know, I'm happy to do the PR. I just need to know that it would be potentially accepted.

@joshribakoff joshribakoff referenced this pull request in zendframework/zf2-documentation Jul 5, 2013

Zend\Validator\Alnum does not exist #935

Zend Framework member

@joshribakoff I understand where you're coming from. The problem we have is maintainability -- we either have two separate Alnum validators (one that is locale aware, another that isn't), and then have confusion over which one is registered and which to use, or we have one, but put it in the context-specific location (i18n namespace). We're getting a lot of pushback lately about dependencies for individual components, which is why we've tended to move anything that has a dependency on another component into that component.

Zend Framework member

@akrabat This PR started as an issue, and I turned it into a PR by adding the commits; can you review, please?

@akrabat akrabat added a commit that closed this pull request Jul 19, 2013
@akrabat akrabat Merge branch 'pr4778'
Close #4778
@akrabat akrabat closed this in 288b3fc Jul 19, 2013
@akrabat akrabat added a commit that referenced this pull request Jul 19, 2013
@akrabat akrabat Merge branch 'pr4778' into develop
Forward port #4778

@weierophinney Fair enough, but do realize lots of unrelated components deal with international characters; such as database queries, forms, filters, validators, configuration containers, even code reflection, etc.. I think its better to accept a dependency than to have the class in a confusing place, but that's subjective at the end of the day. For example forms depend on validators, and that's reasonable. Wouldn't make sense to put forms & validators in the same package though...

@gianarb gianarb pushed a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@akrabat akrabat Merge branch 'pr4778' into develop ef0268c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment