# 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 InvalidURL(ValidationError):
#     """Error raised by `URL` validator"""
# 
#     def __init__(self, invalid, path):
#         """
#         Args:
#             invalid (str): invalid URL
#             path (list): path of the invalid data
#         """
#         message = "Invalid URL : %s" % (invalid)
#         super(InvalidURL, self).__init__(message, path)
#         self.invalid = invalid


from urllib.parse import urlparse
from . import Validator
from ..errors import InvalidURL


class URL(Validator):
    """Validate that value is a well formed URL"""
    def __init__(self, schemes=None):
        """
        Args:
            schemes (set): a set of allowed schemes
        """
        self._schemes = schemes

    def __call__(self, value, path):
        """Validate URL format of value

        Args:
            value (object): value to validate
            path (list): error path
        """
        try:
            result = urlparse(value)
        except AttributeError:

# 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 InvalidURL(ValidationError):
#     """Error raised by `URL` validator"""
# 
#     def __init__(self, invalid, path):
#         """
#         Args:
#             invalid (str): invalid URL
#             path (list): path of the invalid data
#         """
#         message = "Invalid URL : %s" % (invalid)
#         super(InvalidURL, self).__init__(message, path)
#         self.invalid = invalid


# Path: src/lupin/validators/url.py
from urllib.parse import urlparse
from . import Validator
from ..errors import InvalidURL



class URL(Validator):
    """Validate that value is a well formed URL"""
    def __init__(self, schemes=None):
        """
        Args:
            schemes (set): a set of allowed schemes
        """
        self._schemes = schemes

    def __call__(self, value, path):
        """Validate URL format of value

        Args:
            value (object): value to validate
            path (list): error path
        """
        try:
            result = urlparse(value)
        except AttributeError:

            raise InvalidURL(value, path=path)