`DurationMaxValidator` and `DurationMinValidator` annotations allow for zero duration in situations where it may not make logical sense

Description

I was playing around with @DurationMax and @DurationMin and noticed something a bit odd with how they handle zero durations.

  • @DurationMax: It lets you set a maximum duration of zero, even when inclusive is false. Doesn't really make sense, right? If I want a duration to be zero, I shouldn't need this annotation at all.

  • @DurationMin: This one lets me set a minimum duration of zero if I set inclusive = true. It's a bit confusing. If I'm saying "inclusive" it means zero is already a valid input, so why bother with the annotation?

Could we maybe tweak these validators to make them more sensible?
I'm thinking:

  • @DurationMax: Don't allow zero as a maximum, no matter what inclusive is set to.

  • @DurationMin: Don't allow zero as a minimum if inclusive = true.

Let me know what you think!

If you're happy with it, I can try to fix it myself including test cases.

Environment

None

Attachments

1

Activity

Show:

Marko BekhtaDecember 10, 2024 at 12:33 PM

Closing this one as per the discussion above; thanks!

Marko BekhtaOctober 25, 2024 at 7:20 AM

Ohh, okay, I see what you meant now. Yeah, it seems like an Atlassian advertisement. Clicking the three dots on top of the request button has “Why am I seeing this?” and there:

We think Confluence will improve your team's productivity

Shamkhal MaharramovOctober 24, 2024 at 6:02 PM

Ah, okay, I get it now. Didn't think about negative durations!

I’m not sure where you’ve made a request, but we are not using confluence for Hibernate projects

Maybe Jira automatically adds that Confluence link? Not sure why it's there.

Thanks

Marko BekhtaOctober 24, 2024 at 4:37 PM

Hey,

Thanks for bringing up this suggestion. The thing is that duration can be negative ( ), which means that technically, one could say @DurationMax(inclusive = false) Duration duration only to accept strictly negative durations or @DurationMin(inclusive = false) Duration duration for strictly positive ones. I can’t think of a practical use case for a negative duration, maybe as a difference between planned and spent time, where negative duration would show an “overtime”? But in any case, since negative values are allowed, we shouldn’t restrict users from configuring their constraints for 0.

Now as to:

Also, could you please accept my request for Confluence?

I’m not sure where you’ve made a request, but we are not using confluence for Hibernate projects… All the docs (reference, guides, etc.) are in the project repository and then published here: .

Shamkhal MaharramovOctober 24, 2024 at 3:54 PM

It would be helpful to get your thoughts on this.

Also, could you please accept my request for Confluence?

Thanks.

Rejected

Details

Assignee

Reporter

Labels

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Marko Bekhta
Shamkhal Maharramov

Original estimate

Time tracking

No time logged1h remaining

Components

Affects versions

Priority

Created October 16, 2024 at 10:48 AM
Updated February 14, 2025 at 1:40 PM
Resolved December 10, 2024 at 12:33 PM