Respect / Validation

The most awesome validation engine ever created for PHP
https://respect-validation.readthedocs.io
MIT License
5.78k stars 773 forks source link

Rule/date time diff #1463

Open gvieiragoulart opened 1 month ago

gvieiragoulart commented 1 month ago

Resolves https://github.com/Respect/Validation/issues/1462


What?

This PR introduces a new validation rule, DateTimeDiff wich validates the difference of date/time against a specific rule.

The $type argument on our construct should follow PHP's DateInterval properties. So we can use types such as year, months,days,full days,hours,minutes,seconds,microseconds.


Note: This is my first PR in a relatively large open-source project, so if I've done anything incorrectly, please let me know. :+1:

alganet commented 1 month ago

@gvieiragoulart I approved the CI run. There are some static analysis checks you'll need to fix before we can merge this!

I'll keep an eye here to approve the CI run again as soon as you fix them, and once it passes, I'll do a full review!

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 94.11765% with 5 lines in your changes missing coverage. Please review.

Project coverage is 97.28%. Comparing base (d7dc0f2) to head (906f722). Report is 3 commits behind head on main.

Files Patch % Lines
library/Rules/DateTimeDiff.php 93.22% 4 Missing :warning:
library/Helpers/CanExtractRules.php 93.75% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1463 +/- ## ============================================ + Coverage 96.20% 97.28% +1.07% - Complexity 917 950 +33 ============================================ Files 199 200 +1 Lines 2109 2206 +97 ============================================ + Hits 2029 2146 +117 + Misses 80 60 -20 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.