# 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 InvalidIn(ValidationError):
#     """Error raised by `In` validator"""
# 
#     def __init__(self, invalid, expected, path):
#         """
#         Args:
#             invalid (str): invalid value
#             expected (list): list of expected values
#             path (list): path of the invalid data
#         """
#         message = "Value \"%s\" is not in %s" % (invalid, expected)
#         super(InvalidIn, self).__init__(message, path)
#         self.invalid = invalid
#         self.expected = expected


from . import Validator
from ..errors import InvalidIn


class In(Validator):
    """Validates that a value is contained in a set of values"""

    def __init__(self, values):
        """
        Args:
            values (set|list|tuple): expected values
        """
        self._values = values

    def __call__(self, value, path):
        """Validate that value is contained in the expected ones

        Args:
            value (object): value to validate
            path (list): error path
        """
        if value not in self._values:

# 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 InvalidIn(ValidationError):
#     """Error raised by `In` validator"""
# 
#     def __init__(self, invalid, expected, path):
#         """
#         Args:
#             invalid (str): invalid value
#             expected (list): list of expected values
#             path (list): path of the invalid data
#         """
#         message = "Value \"%s\" is not in %s" % (invalid, expected)
#         super(InvalidIn, self).__init__(message, path)
#         self.invalid = invalid
#         self.expected = expected


# Path: src/lupin/validators/in_validator.py
from . import Validator
from ..errors import InvalidIn



class In(Validator):
    """Validates that a value is contained in a set of values"""

    def __init__(self, values):
        """
        Args:
            values (set|list|tuple): expected values
        """
        self._values = values

    def __call__(self, value, path):
        """Validate that value is contained in the expected ones

        Args:
            value (object): value to validate
            path (list): error path
        """
        if value not in self._values:

            raise InvalidIn(value, self._values, path)