from typing import Union


def clamp(value: Union[float, int],
          minvalue: Union[float, int],
          maxvalue: Union[float, int]) \
        -> Union[float, int]:
    """
    Clamps the value to a minimum and maximum
    :param value: source value
    :param minvalue: min possible value
    :param maxvalue: max possible value
    :return: clamped value
    """
    return min(max(minvalue, value), maxvalue)