I'm working on an application where I'm entering multiple price ranges. I want to validate the price range to keep it from overlapping with another price range. I know how to check whether two arrays overlaps or not, e.g.,
a = [1.0, 2.0]
b = [2.0, 3.0]
a & b #=> true
I have two fields price_start and price_end, so no price range between these two fields should overlap with another
But here its a range, e.g. $1.0 - $10.0 then the next one $10.1 to $20, how we can implement this? please help! thanks