Skip to content

Fix invalidMessage in Range constraint #35998

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number.</source>
<target>Dieser Wert sollte eine gültige Zahl sein.</target>
<target>Dieser Wert sollte eine gültige Zahl oder gültigen Datums- und Zeitangabe sein.</target>
</trans-unit>
<trans-unit id="36">
<source>This file is not a valid image.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number.</source>
<target>This value should be a valid number.</target>
<target>This value should be a valid number or a valid datetime.</target>
Copy link
Member

Choose a reason for hiding this comment

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

this is displayed in the final UI,isn't it?
in the UI context, it might be strange to display this "or" - in a field where only a number has meaning.
Is this valid concern? Can we do something about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add a second invalid message and refactor the RangeValidator a little, so that at least you don't get the message This value should be a valid number., when it's clear that you're validating datetimes, e.g. in the following scenario:

$this->validator->validate('foo', new Range(['min' => '2020-01-01', 'max' => '2020-01-31']));

While we're at it, we could also add two more messages, so that when datetime exceeds limit, you would get an earlier / later info instead of more / less.

Copy link
Member

Choose a reason for hiding this comment

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

I think adding dedicated messages is a better idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, adding new message means, that I should switch to master. If so, I will close this PR and I will prepare a separate one.

Copy link
Member

Choose a reason for hiding this comment

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

You can add a new message in 3.4 as it fixes a display bug.

</trans-unit>
<trans-unit id="36">
<source>This file is not a valid image.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number.</source>
<target>Este valor debería ser un número válido.</target>
<target>Este valor debería ser un número válido o una fecha y hora válidas.</target>
</trans-unit>
<trans-unit id="36">
<source>This file is not a valid image.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number.</source>
<target>Ta wartość powinna być prawidłową liczbą.</target>
<target>Ta wartość powinna być prawidłową liczbą lub prawidłową datą i czasem.</target>
</trans-unit>
<trans-unit id="36">
<source>This file is not a valid image.</source>
Expand Down