-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Format datetime values in comparison constraints with dateFormat
option
#39857
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
Conversation
f019cc3
to
64f3fc5
Compare
src/Symfony/Component/Validator/Constraints/AbstractComparison.php
Outdated
Show resolved
Hide resolved
64f3fc5
to
9395d1d
Compare
56fe8dd
to
3873d69
Compare
I have three concerns with the proposed solution:
I tried to resolve this issue at least 3 times but never came out with something good enough to me. I think the difficulty is that the formatting logic is internal to |
i'd be generally curious if we can move formatting to the translation level using ICU formats. eg. to avoid duplicating the message, perhaps a special translation key solely for date values. |
That could be a solution the default value should be full date format as that is how it is now |
3873d69
to
62a7952
Compare
62a7952
to
478b8ec
Compare
I'm facing the issue where the tests do not provide the intl extension and tests break... I don't know what is the right way to fix it. |
dateFormat
option
I'm very interesting about this feature. What is missing for the PR will be merged ? |
Closing for the reasons explained by @fancyweb |
I have introduced a new option for comparison constraints called
dateFormat
. This option gives the ability to use a different format for datetime values in the following placeholders:{{ value }}
and{{ compared_value }}
.Before:
will output:
This value should be greater than Jan 1, 2020, 12:00 AM
.After:
will output:
This value should be greater than 2020-01-01.