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

fix redundance errors "The input does not appear to be a valid date" show twice #2633

Closed

Conversation

samsonasik
Copy link
Contributor

Fix The input does not appear to be a valid date that show twice.

@weierophinney
Copy link
Member

Please add a unit test for this; it's hard to tell what exactly this fix accomplishes currently.

@ghost ghost assigned weierophinney Oct 2, 2012
@samsonasik
Copy link
Contributor Author

@weierophinney : I added a unit test, and the result of markup of element rendered is success. not twice. but if :

if (false === $date || $errors['warning_count'] > 0) {
is in the line of 131 in Zend\Validator\Date, the error that rendered by formRow() helper show twice like this :

http://samsonasik.files.wordpress.com/2012/10/screen-shot-2012-10-03-at-12-16-13-pm.png

and if i remove
(false === $date)
and run
if ($errors['warning_count'] > 0) {
the error show Once only.

weierophinney added a commit that referenced this pull request Oct 3, 2012
- Trailing whitespace
weierophinney added a commit that referenced this pull request Oct 3, 2012
weierophinney added a commit that referenced this pull request Oct 3, 2012
- Fix in #2633, while mostly correct, let $date with bool false value
  continue as valid, which it should not. Added another conditional,
  which ensures reported issue still is fixed, while keeping original
  behavior.
@samsonasik
Copy link
Contributor Author

@weierophinney : how about :

if ($errors['warning_count'] > 0) {
    $this->error(self::INVALID_DATE); 
} 
if ($date === false) {
    $this->error(self::INVALID_DATE);
}
if ($this->error(self::INVALID_DATE)) {
    return false;
}

OR, what about :

if ($date === false && $errors['warning_count'] > 0) {
    $this->error(self::INVALID_DATE); 
}

The && operator fix this problem.
I try both that and correct the problem. the return is in the last, not early ;).
If you agree, i will re-request the pull.

weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
- Fix in zendframework/zendframework#2633, while mostly correct, let $date with bool false value
  continue as valid, which it should not. Added another conditional,
  which ensures reported issue still is fixed, while keeping original
  behavior.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants