Skip to content

Use format for error message dates when unset (#709)#790

Open
WarLikeLaux wants to merge 3 commits intoyiisoft:masterfrom
WarLikeLaux:use-format-for-error-message-dates
Open

Use format for error message dates when unset (#709)#790
WarLikeLaux wants to merge 3 commits intoyiisoft:masterfrom
WarLikeLaux:use-format-for-error-message-dates

Conversation

@WarLikeLaux
Copy link
Copy Markdown

Q A
Is bugfix?
New feature?
Tests added? ✔️
Breaks BC? ✔️
Fixed issues #709

What does this PR do?

In date rules, use format property for formatting dates in error messages when messageFormat and messageDateType/messageTimeType are not set.

BC break

When format is set but messageFormat is not, dates in error messages are now formatted using format instead of IntlDateFormatter::SHORT.

Before:

new Date(format: 'php:d.m.Y', max: '31.12.2099');
// error: "Value must be no late than 12/31/99."

After:

new Date(format: 'php:d.m.Y', max: '31.12.2099');
// error: "Value must be no late than 31.12.2099."

To keep the old behavior, set messageFormat or messageDateType explicitly.

Coverage

Tests: 77 → 80. Line coverage: 115/115 (100%) → 119/119 (100%). MSI: 95% (111/116) → 95% (118/123).

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.55%. Comparing base (fe63447) to head (9821a46).
⚠️ Report is 96 commits behind head on master.

Files with missing lines Patch % Lines
src/Rule/Date/BaseDateHandler.php 0.00% 6 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (fe63447) and HEAD (9821a46). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (fe63447) HEAD (9821a46)
6 5
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #790       +/-   ##
============================================
- Coverage     94.40%   9.55%   -84.85%     
- Complexity      953    1047       +94     
============================================
  Files           108     122       +14     
  Lines          3018    3234      +216     
============================================
- Hits           2849     309     -2540     
- Misses          169    2925     +2756     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates date/time validation error message formatting so that when message-specific formatting options aren’t provided, the rule’s format is used to render limit values in error messages (addressing #709). This changes default error message output and is a documented BC break.

Changes:

  • Update BaseDateHandler::formatDate() to fall back to the rule’s format when message format/type options are unset.
  • Adjust existing date/time rule tests to match the new formatting behavior.
  • Add new test cases to verify precedence between format and message-format settings.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Rule/Date/BaseDateHandler.php Implements fallback to rule format for error-message date/time formatting when message formatting isn’t configured.
tests/Rule/Date/DateTest.php Updates expectations and adds coverage for format-driven message formatting and messageFormat override behavior.
tests/Rule/Date/DateTimeTest.php Updates expected min/max/timestamp error message formatting to use the rule format.
tests/Rule/Date/TimeTest.php Updates expected time error message formatting and adds a precedence test for format vs handler message type.
CHANGELOG.md Adds a changelog entry for the behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants