def isMonthRange()

in src/guclimate/requests/validate.py [0:0]


def isMonthRange(_, current):
    stripped = current.strip()
    error = errors.ValidationError("", reason=f"{current} is not a valid month range")

    pattern = re.compile("^[0-9]{1,2}-[0-9]{1,2}$")
    if pattern.match(stripped) is None:
        raise error

    [first, last] = [int(value) for value in stripped.split("-")]
    # check that values are between 1 and 12
    if first < 1 or first > 12 or last < 1 or last > 12:
        raise error

    # check that last is greater than first
    if last <= first:
        raise error

    return True