Skip to content

[Validator] Sync string to date behavior and throw a better exception #33439

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

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Sep 3, 2019

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

\DateTimeImmutable are not compared with \DateTimeImmutable in the RangeValidator class (contrary to the behavior in the AbstractComparisonValidator class).
Also, let's throw a dedicated exception when the provided string value cannot be parsed to a \DateTime or \DateTimeImmutable. It's better than the default exception IMO.

@fancyweb fancyweb force-pushed the validator-better-throw-on-invalid-dates branch from 10873a4 to 28d7d94 Compare September 3, 2019 09:02
@fabpot
Copy link
Member

fabpot commented Sep 3, 2019

Thank you @fancyweb.

fabpot added a commit that referenced this pull request Sep 3, 2019
…r exception (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Sync string to date behavior and throw a better exception

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

`\DateTimeImmutable` are not compared with `\DateTimeImmutable` in the `RangeValidator` class (contrary to the behavior in the `AbstractComparisonValidator` class).
Also, let's throw a dedicated exception when the provided string value cannot be parsed to a `\DateTime` or `\DateTimeImmutable`. It's better than the default exception IMO.

Commits
-------

28d7d94 [Validator] Sync string to date behavior and throw a better exception
@fabpot fabpot merged commit 28d7d94 into symfony:3.4 Sep 3, 2019
@fancyweb fancyweb deleted the validator-better-throw-on-invalid-dates branch September 3, 2019 16:16
@nicolas-grekas
Copy link
Member

@fancyweb can you please submit the PR for 4.3? I don't know how to merge it and make tests pass. Thanks for your help.

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