# Path: src/lupin/validators/validator.py
# class Validator(object):
#     """Validators base class"""
# 
#     def __and__(self, other):
#         """Combine current validator with another one using the & operator
# 
#         Returns:
#             ValidatorsAndCombination
#         """
#         return lupin.ValidatorsAndCombination([self, other])
# 
#     def __or__(self, other):
#         """Combine current validator with another one using the | operator
# 
#         Returns:
#             ValidatorsOrCombination
#         """
#         return lupin.ValidatorsOrCombination([self, other])
# 
# Path: src/lupin/errors.py
# class InvalidRange(ValidationError):
#     """Error raised by `Between` validator"""
# 
#     def __init__(self, value, min, max, path):
#         """
#         Args:
#             value (int): value received
#             min (int): minimum value
#             max (int): maximum value
#             path (list): path of the invalid data
#         """
#         message = "%s is not between %s and %s" % (value, min, max)
#         super(InvalidRange, self).__init__(message, path)
#         self.max = max
#         self.min = min
#         self.value = value


from . import Validator
from ..errors import InvalidRange


class Between(Validator):
    """Validates that a value is contained within bounds"""
    def __init__(self, min=None, max=None, include_min=True, include_max=True):
        """
        Args:
            min (int): minimum value
            max (int): maximum value
            include_min (bool): include min value
            include_max (bool): include max value
        """
        self._min = min
        self._max = max
        self._include_min = include_min
        self._include_max = include_max

    def __call__(self, value, path):
        """Validate that value is contained is the range

        Args:
            value (object): value to validate
            path (list): error path
        """
        try:
            if self._min is not None and\
                    (self._include_min and value < self._min or
                     not self._include_min and value <= self._min) or\
                    value is None:

# Path: src/lupin/validators/validator.py
# class Validator(object):
#     """Validators base class"""
# 
#     def __and__(self, other):
#         """Combine current validator with another one using the & operator
# 
#         Returns:
#             ValidatorsAndCombination
#         """
#         return lupin.ValidatorsAndCombination([self, other])
# 
#     def __or__(self, other):
#         """Combine current validator with another one using the | operator
# 
#         Returns:
#             ValidatorsOrCombination
#         """
#         return lupin.ValidatorsOrCombination([self, other])
# 
# Path: src/lupin/errors.py
# class InvalidRange(ValidationError):
#     """Error raised by `Between` validator"""
# 
#     def __init__(self, value, min, max, path):
#         """
#         Args:
#             value (int): value received
#             min (int): minimum value
#             max (int): maximum value
#             path (list): path of the invalid data
#         """
#         message = "%s is not between %s and %s" % (value, min, max)
#         super(InvalidRange, self).__init__(message, path)
#         self.max = max
#         self.min = min
#         self.value = value


# Path: src/lupin/validators/between.py
from . import Validator
from ..errors import InvalidRange



class Between(Validator):
    """Validates that a value is contained within bounds"""
    def __init__(self, min=None, max=None, include_min=True, include_max=True):
        """
        Args:
            min (int): minimum value
            max (int): maximum value
            include_min (bool): include min value
            include_max (bool): include max value
        """
        self._min = min
        self._max = max
        self._include_min = include_min
        self._include_max = include_max

    def __call__(self, value, path):
        """Validate that value is contained is the range

        Args:
            value (object): value to validate
            path (list): error path
        """
        try:
            if self._min is not None and\
                    (self._include_min and value < self._min or
                     not self._include_min and value <= self._min) or\
                    value is None:

                raise InvalidRange(value, self._min, self._max, path=path)