Prevent Adding Record within To/From Range

Prevent Adding Record within To/From Range

I have a form that has  "To" and "From" fields for a range of days (e.g. FROM 0 TO 30). There are multiple records in the table

From      To
0            30
31          60
60          90

I would like to prevent the user from adding a new record between these numbers on the form.

I tried to do this with a on validate action as follows, but it does not seem to work:

if (count(Cancellation_Policy[((Property_Code == input.Property_Code && From_Days >= input.From_Days) && To_Days <= input.To_Days)])  >  0)
{
    alert ("A cancellation policy already exists for this range of days");
    cancel submit;
}

Is this possible?