Open
Description
Description
My application uses the Range
constraint to validate against relative date ranges like this:
#[Assert\Range(
notInRangeMessage: 'Date out of range: Must not be older than 40 days and not in the future',
min: '-40 days',
max: 'now',
)]
When testing the application, I'd love to leverage Symfony's clock to pin the current date to a fixture. However, the RangeValidator
as well as comparison validators like GreaterThanValidator
and friends are not aware of the clock.
Simply making them aware of the clock won't solve the problem because we would suddenly need to distinguish between absolute date strings like 'March 1st 2025'
and relative ones like '2 days ago'
.
Example
No response