Skip to content

[Validator] Add invalid datetime message in Range validator #36326

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 24, 2020

Conversation

przemyslaw-bogusz
Copy link
Contributor

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

When the validated value is invalid (it isn't a number nor a datetime), but min or max option indicate that the Range constraint is being used to validate a datetime, the displayed message will be This value should be a valid datetime instead of This value should be a valid number. This PR replaces #35998.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 16, 2020

min or max option indicate that the Range

since this is using some heuristic logic, I would suggest reporting this when min AND max are can be parsed as dates.

@fabpot
Copy link
Member

fabpot commented Aug 12, 2020

@przemyslaw-bogusz Any comments about @nicolas-grekas suggestion?

@przemyslaw-bogusz
Copy link
Contributor Author

@nicolas-grekas I've modified the PR. As I understand, if one of the boundries is null and the other one is parsable DateTime string, this should also return invalidDateTimeMessage instead of invalidMessage?

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

This should be rebased on master as this is a new feature.

@fabpot
Copy link
Member

fabpot commented Sep 19, 2020

@przemyslaw-bogusz I think you're right for your latest question. Still willing to finish this PR for master?

@fabpot fabpot force-pushed the range_invalid_message branch from 69792c2 to c777306 Compare September 24, 2020 14:49
@fabpot
Copy link
Member

fabpot commented Sep 24, 2020

Thank you @przemyslaw-bogusz.

@fabpot fabpot merged commit 2bdcf4a into symfony:master Sep 24, 2020
@fabpot fabpot mentioned this pull request Oct 5, 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