Jmix Version: 2.2.1.1
Plugin Version: 2.2.1-233
Observed behavior:
When annotating either a LocalDate
or a LocalDateTime
with @PastOrPresent
, the validation seems to check against the startup time of the application, not against the current time as expected.
Steps to reproduce:
- Create a new Jmix project
- Add one Entity with a
LocalDateTime
field - Add a
@PastOrPresent
validator to this field - Add a view for the entity which allows creation of a new instance
- Start the application
- Try to create a new entity with current local date time as observed from the local system clock
- Wait 2 Minutes
- Try to create a new entity with current local date time as observed from the local system clock minus one minute
- Observe that the validation fails
Notes:
- Unfortunately I could not load up a zip archive of a minimal example (as described above) as it exceeded the max size of 4MB slightly. Please consider raising the upload limit.
- I also made a small video demonstrating the effect, but could not upload it as a/ .mp4 files are not accepted and b/ .mov files are bigger than 4MB. Please consider accepting mp4 files. I have now uploaded the video to the public internet.
- I have successfully reproduced this both for
LocalDate
andLocalDateTime
fields. I also suspect that this behavior might be present for other temporals. - The behavior appears to be platform idenpendent as I could both verify it under MacOS as well as in a docker container running inside Ubuntu.
- Superficial investigation suggests that maybe the root cause can be found in
ValidationClockProvider
(packageio.jmix.core.impl.validation
) line 37:return Clock.fixed(now.toInstant(), now.getZone());
- maybe the Clock.fixed might be the issue. - If this is indeed the case, I would suspect that the behavior is not limited to this validator alone.
Thank you for investigating and best regards,
Dominik