Skip to content

DateTime validator support for trailing data #37097

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

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

stefankleff
Copy link

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #37094
License MIT

@@ -68,6 +68,8 @@ public function validate($value, Constraint $constraint)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(DateTime::INVALID_TIME_ERROR)
->addViolation();
} elseif ('Trailing data' === $warning && '+' === substr($constraint->format, -1)) {
Copy link
Member

@xabbuh xabbuh Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be cases with more than one warning where we don't want to ignore the other ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefankleff any idea? Could you please have a look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefankleff Have you time to have a look at this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not yet. But I'll try within this week.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

friendly ping

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case is valid, that we have a "+" in the format and we don't want to ignore the other warnings.
I couldn't find a better way than remove the warning from the list of warnings.
I also looked in the underlying c-code and I couldn't find any similar cases to trailing data.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jun 4, 2020
@fabpot fabpot force-pushed the datetime-validator-trailing-data branch from f3b8721 to 27f6e28 Compare September 9, 2020 05:34
@fabpot
Copy link
Member

fabpot commented Sep 9, 2020

Thank you @stefankleff.

@fabpot fabpot merged commit 1e52146 into symfony:3.4 Sep 9, 2020
This was referenced Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants