# Path: src/lupin/validators/is_none.py
# class IsNone(Validator):
#     """Validate that a value is None"""
# 
#     def __call__(self, value, path):
#         """Validate that value is None
# 
#         Args:
#             value (object): value to validate
#             path (list): error path
#         """
#         if value is not None:
#             raise NotNone(value, path)
# 
# Path: src/lupin/processors.py
# def null_processor(value):
#     """Processor that does nothing, just returns the value"""
#     return value


import warnings
from functools import reduce
from lupin import ValidatorsAndCombination, ValidatorsNullCombination
from ..validators import IsNone
from ..processors import null_processor


class Field(object):
    """Generic field that does not convert the values"""

    def __init__(self, binding=None, default=None, validators=None, read_only=False, write_only=False,
                 optional=False, allow_none=False, pre_load=None, post_load=None,
                 pre_dump=None, post_dump=None, ignore_if_null=False):
        """
        Args:
            binding (str): attribute name to map on object
            default (object): default value if data is absent
            validators (list|ValidatorsCombination|Validator): list of validators or a combination a validators
            read_only (bool): if True the field will only be used to serialize data
            write_only (bool): if True the field will only be used to load data
            optional (bool): if True it won't raise an error if no value provided for this field
            allow_none (bool): if True None is a accepted has a valid value
            pre_load (list): list of processors to execute before loading the value
            post_load (list): list of processors to execute after loading the value
            pre_dump (list): list of processors to execute before dumping the value
            post_dump (list): list of processors to execute after dumping the value
            ignore_if_null (bool): if True the fields will not be serialize when null
        """
        if validators is None:
            validators = ValidatorsNullCombination()
        elif isinstance(validators, (list, tuple)):
            warnings.warn("List of validators is deprecated, please use combinations (&|)", DeprecationWarning)
            validators = ValidatorsAndCombination(validators)

        if allow_none:

# Path: src/lupin/validators/is_none.py
# class IsNone(Validator):
#     """Validate that a value is None"""
# 
#     def __call__(self, value, path):
#         """Validate that value is None
# 
#         Args:
#             value (object): value to validate
#             path (list): error path
#         """
#         if value is not None:
#             raise NotNone(value, path)
# 
# Path: src/lupin/processors.py
# def null_processor(value):
#     """Processor that does nothing, just returns the value"""
#     return value


# Path: src/lupin/fields/field.py
import warnings
from functools import reduce
from lupin import ValidatorsAndCombination, ValidatorsNullCombination
from ..validators import IsNone
from ..processors import null_processor



class Field(object):
    """Generic field that does not convert the values"""

    def __init__(self, binding=None, default=None, validators=None, read_only=False, write_only=False,
                 optional=False, allow_none=False, pre_load=None, post_load=None,
                 pre_dump=None, post_dump=None, ignore_if_null=False):
        """
        Args:
            binding (str): attribute name to map on object
            default (object): default value if data is absent
            validators (list|ValidatorsCombination|Validator): list of validators or a combination a validators
            read_only (bool): if True the field will only be used to serialize data
            write_only (bool): if True the field will only be used to load data
            optional (bool): if True it won't raise an error if no value provided for this field
            allow_none (bool): if True None is a accepted has a valid value
            pre_load (list): list of processors to execute before loading the value
            post_load (list): list of processors to execute after loading the value
            pre_dump (list): list of processors to execute before dumping the value
            post_dump (list): list of processors to execute after dumping the value
            ignore_if_null (bool): if True the fields will not be serialize when null
        """
        if validators is None:
            validators = ValidatorsNullCombination()
        elif isinstance(validators, (list, tuple)):
            warnings.warn("List of validators is deprecated, please use combinations (&|)", DeprecationWarning)
            validators = ValidatorsAndCombination(validators)

        if allow_none:

            validators = IsNone() | validators