Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix to make sure NotEmpty validator is not already set #3683

Closed
wants to merge 1 commit into from

3 participants

@grizzm0

The InArray validator on select/radio elements are added before the NotEmpty validator and therefore \Zend\InputFilter:input::injectNotEmptyValidator() fails and overrides any custom NotEmpty validator.

Fixes #3678

@mwillbanks
Collaborator

Please supply a unit test for this behavior :+1:

@grizzm0

I'm not that into tests myself, could you perhaps help me out with this? ;)

@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3683] Added unit test for behavior
- Allows NotEmpty validator anywhere in chain (not just as first
  validator in chain)
aae8fcd
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3683' into develop
Forward port #3683
21e9e2c
@weierophinney weierophinney closed this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3683'
Close #3683
Fixes #3678
fe56fe7
@weierophinney weierophinney was assigned
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3683] Added unit test for behavior
- Allows NotEmpty validator anywhere in chain (not just as first
  validator in chain)
7cd8310
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3683'
Close #3683
Fixes #3678
0560b18
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3683' into develop
Forward port #3683
7868119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 library/Zend/InputFilter/Input.php
View
12 library/Zend/InputFilter/Input.php
@@ -313,13 +313,13 @@ protected function injectNotEmptyValidator()
}
$chain = $this->getValidatorChain();
- // Check if NotEmpty validator is already first in chain
+ // Check if NotEmpty validator is already in chain
$validators = $chain->getValidators();
- if (isset($validators[0]['instance'])
- && $validators[0]['instance'] instanceof NotEmpty
- ) {
- $this->notEmptyValidator = true;
- return;
+ foreach ($validators as $validator) {
+ if ($validator['instance'] instanceof NotEmpty) {
+ $this->notEmptyValidator = true;
+ return;
+ }
}
$chain->prependByName('NotEmpty', array(), true);
Something went wrong with that request. Please try again.