AlkantarClanX12

Your IP : 3.144.255.116


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/cerberus/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/cerberus/__pycache__/validator.cpython-311.pyc

�

m��f����b�ddlmZddlmZddlmZddlmZmZddlZddlm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZmZdd	lmZmZmZmZdd
lmZmZmZej��Zd�Z Gd�d
e!��Z"Gd�de!��Z#Gd�de$��Z%dZ&Gd�de'��Z(e(de%fi��Z)dS)�)�absolute_import)�literal_eval)�copy)�date�datetimeN)�warn)�errors)�
_int_types�	_str_type�	Container�Hashable�Iterable�Mapping�Sequence�Sized)�schema_registry�rules_set_registry�DefinitionSchema�SchemaError)�drop_item_from_tuple�readonly_classproperty�TypeDefinitionc��d�}|}||_|S)Nc� �td���)NzcDummy method called. Its purpose is to hold justvalidation constraints for a rule in its docstring.)�RuntimeError)�self�
constraint�field�values    �I/opt/imunify360/venv/lib64/python3.11/site-packages/cerberus/validator.py�dummyz(dummy_for_rule_validation.<locals>.dummy s���
�
�
�	
�)�__doc__)�rule_constraintsr!�fs   r �dummy_for_rule_validationr&s$��
�
�
�	�A� �A�I��Hr"c��eZdZdZdS)�
DocumentErrorzBRaised when the target document is missing or has the wrong formatN��__name__�
__module__�__qualname__r#�r"r r(r(,s������L�L��Dr"r(c��eZdZdZdS)�_SchemaRuleTypeErrorzw
    Raised when a schema (list) validation encounters a mapping.
    Not supposed to be used outside this module.
    Nr)r-r"r r/r/2s��������
	�Dr"r/c�4��eZdZdZdZ	dZ	edeefd��ede	fd��ede
fef��edefd��ed	e
fd��ed
efd��edeefd��edefd��ed
efef��edeefe	f��edefd��edefd��d�Z	e��Z	�fd�Zed���Zd�Zed���Zd�Zdrd�Zd�Zd�Zd�Zd�Z d�Z!e"d���Z#e#j$d���Z#e"d ���Z%e%j$d!���Z%e"d"���Z&e"d#���Z'e'j$d$���Z'e"d%���Z(e"d&���Z)e)j$d'���Z)e"d(���Z*e*j$d)���Z*e"d*���Z+e+j$d+���Z+e"d,���Z,e"d-���Z-e"d.���Z.e"d/���Z/e/j$d0���Z/e"d1���Z0e"d2���Z1e1j$d3���Z1e"d4���Z2e2j$d5���Z2e3d6���Z4dsd7�Z5d8�Z6dtd:�Z7d;�Z8d<�Z9d=�Z:d>�Z;d?�Z<d@�Z=dA�Z>dB�Z?dC�Z@edD���ZAedE���ZBdF�ZCdG�ZDdH�ZEdI�ZFdJ�ZGdK�ZHdL�ZIdudN�ZJeJZKdO�ZLdP�ZMdQ�ZNeOdR��ZPdS�ZQdT�ZRdU�ZSdV�ZTdW�ZUdX�ZVdY�ZWdZ�ZXd[�ZYd\�ZZd]�Z[d^�Z\d_�Z]d`�Z^da�Z_db�Z`dc�Zadd�ZbeOde��Zcdf�Zddg�Zedh�Zfdi�Zgdj�ZheOdk��ZieOdk��Zjdl�Zkdm�Zldn�Zmdo�Zndp�Zodq�Zp�xZqS)v�
BareValidatora�	
    Validator class. Normalizes and/or validates any mapping against a
    validation-schema which is provided as an argument at class instantiation
    or upon calling the :meth:`~cerberus.Validator.validate`,
    :meth:`~cerberus.Validator.validated` or
    :meth:`~cerberus.Validator.normalized` method. An instance itself is
    callable and executes a validation.

    All instantiation parameters are optional.

    There are the introspective properties :attr:`types`, :attr:`validators`,
    :attr:`coercers`, :attr:`default_setters`, :attr:`rules`,
    :attr:`normalization_rules` and :attr:`validation_rules`.

    The attributes reflecting the available rules are assembled considering
    constraints that are defined in the docstrings of rules' methods and is
    effectively used as validation schema for :attr:`schema`.

    :param schema: See :attr:`~cerberus.Validator.schema`.
                   Defaults to :obj:`None`.
    :type schema: any :term:`mapping`
    :param ignore_none_values: See :attr:`~cerberus.Validator.ignore_none_values`.
                               Defaults to ``False``.
    :type ignore_none_values: :class:`bool`
    :param allow_unknown: See :attr:`~cerberus.Validator.allow_unknown`.
                          Defaults to ``False``.
    :type allow_unknown: :class:`bool` or any :term:`mapping`
    :param require_all: See :attr:`~cerberus.Validator.require_all`.
                        Defaults to ``False``.
    :type require_all: :class:`bool`
    :param purge_unknown: See :attr:`~cerberus.Validator.purge_unknown`.
                          Defaults to to ``False``.
    :type purge_unknown: :class:`bool`
    :param purge_readonly: Removes all fields that are defined as ``readonly`` in the
                           normalization phase.
    :type purge_readonly: :class:`bool`
    :param error_handler: The error handler that formats the result of
                          :attr:`~cerberus.Validator.errors`.
                          When given as two-value tuple with an error-handler
                          class and a dictionary, the latter is passed to the
                          initialization of the error handler.
                          Default: :class:`~cerberus.errors.BasicErrorHandler`.
    :type error_handler: class or instance based on
                         :class:`~cerberus.errors.BaseErrorHandler` or
                         :class:`tuple`
    )�nullable)r2�readonly�type�empty�binaryr-�boolean�	containerrr�dict�float�integer�list�number�set�string)r6r7r8rrr9r:r;r<r=r>r?c�N��d|_	tj��|_	d|_	tj��|_	tj��|_	d|_		d|_
	d|_|�|��|_
	|�||��|�dd��|_|�dd��|_|�dd��|_g|_	t)t*|�����dS)a4
        The arguments will be treated as with this signature:

        __init__(self, schema=None, ignore_none_values=False,
                 allow_unknown=False, require_all=False,
                 purge_unknown=False, purge_readonly=False,
                 error_handler=errors.BasicErrorHandler)
        Nr-F�schema�
allow_unknown�require_all)�documentr	�	ErrorList�_errors�recent_error�DocumentErrorTree�document_error_tree�SchemaErrorTree�schema_error_tree�
document_path�schema_path�update�"_BareValidator__init_error_handler�
error_handler�_BareValidator__store_config�getrArBrC�_remaining_rules�superr1�__init__)r�args�kwargs�	__class__s   �r rUzBareValidator.__init__�s/�����
�	*��'�)�)���	:�!���	@�#)�#;�#=�#=�� �	B�"(�!7�!9�!9���	@� ���	%����	%����!�6�6�v�>�>���	A�	
���D�&�)�)�)��j�j��4�0�0���#�Z�Z���?�?���!�:�:�m�U�;�;��� "���	$�	�m�T�"�"�+�+�-�-�-�-�-r"c�@�|�dtj��}t|t��r|\}}ni}t|t
��r"t
|tj��r|di|��St|tj��r|Std���)NrPzInvalid error_handler.r-)	�popr	�BasicErrorHandler�
isinstance�tupler4�
issubclass�BaseErrorHandlerr)rWrP�	eh_configs   r �__init_error_handlerz"BareValidator.__init_error_handler�s����
�
�?�F�4L�M�M�
��m�U�+�+�	�'4�$�M�9�9��I��m�T�*�*�	9�z��6�2�0
�0
�	9�!�=�-�-�9�-�-�-�
�
�v�'>�
?�
?�	9� � ��7�8�8�8r"c��d}t|dt|�����D]&\}}||vrtd|z���||||<�'||_dS)z.Assign args to kwargs and store configuration.)rA�ignore_none_valuesrBrC�
purge_unknown�purge_readonlyNz.__init__ got multiple values for argument '%s')�	enumerate�len�	TypeError�_config)rrVrW�	signature�i�ps      r �__store_configzBareValidator.__store_config�ss��
�	��i��#�d�)�)��4�5�5�	$�	$�D�A�q��F�{�{�� S�VW� W�X�X�X� ��G��q�	�	����	#�	#r"c�8�|j���dS)z'Purge the cache of known valid schemas.N)�_valid_schemas�clear)�clss r �clear_cacheszBareValidator.clear_caches�s��	�� � �"�"�"�"�"r"c	��t|��dkr�|j�|d��|j���|dD]P}|j�|��|j�|��|j�|���QdSt|��dkrJt|dt��r/|�|dtj
|d��dSt|��dk�r7|d}|dj}|dj}|dd�}|j|fz}|j}|tjjkr	|�|||fz
}|sd}	n�|�|�|j��|��}
|dkr|
�|d��}	n0|dkr"|
�||j��}	||
vrd}n|
|}	|j�|��}tj|||||	||��|_|�|jg��dSdS)	a
        Creates and adds one or multiple errors.

        :param args: Accepts different argument's signatures.

                     *1. Bulk addition of errors:*

                     - :term:`iterable` of
                       :class:`~cerberus.errors.ValidationError`-instances

                     The errors will be added to
                     :attr:`~cerberus.Validator._errors`.

                     *2. Custom error:*

                     - the invalid field's name

                     - the error message

                     A custom error containing the message will be created and
                     added to :attr:`~cerberus.Validator._errors`.
                     There will however be fewer information contained in the
                     error (no reference to the violated rule and its
                     constraint).

                     *3. Defined error:*

                     - the invalid field's name

                     - the error-reference, see :mod:`cerberus.errors`

                     - arbitrary, supplemental information about the error

                     A :class:`~cerberus.errors.ValidationError` instance will
                     be created and added to
                     :attr:`~cerberus.Validator._errors`.
        �r�Nr2F�required�__require_all__)rgrF�extend�sortrI�addrKrP�emitr\r�_errorr	�CUSTOM�code�rulerLrM�
UNKNOWN_FIELD�_resolve_rules_set�_resolve_schemarArRrCrD�ValidationErrorrG)rrV�errorrr~r�inforLrMr�	rules_setrs            r r|zBareValidator._error�s`��L�t�9�9��>�>��L����Q��(�(�(��L�������a��
/�
/���(�,�,�U�3�3�3��&�*�*�5�1�1�1��"�'�'��.�.�.�.�
/�
/���Y�Y�!�^�^�
�4��7�I� >� >�^��K�K��Q�����Q��8�8�8�8�8�
��Y�Y�!�^�^���G�E���7�<�D���7�<�D�����8�D� �.�%��9�M��*�K��v�+�0�0�0�T�5E���t�}�,���

1�!�
�
� �3�3��(�(���5�5�e�<���	��:�%�%�!*���t�U�!;�!;�J�J��Z�'�'�!*���t�T�5E�!F�!F�J��9�,�,�&7���!*�4��J��M�%�%�e�,�,�E� &� 6��{�D�$�
�E�4�!�!�D��
�K�K��*�+�,�,�,�,�,�A�^r"Nc���|j���}|�|��|js7d|d<t|d<|j|d<|j|d<|j|d<|j|d<|j	d	i|��}|�
|j
|_
n't|t��s|f}|j
|z|_
|�
|j
|_
n't|t��s|f}|j
|z|_
|S)
a@
        Creates a new instance of Validator-(sub-)class. All initial parameters of the
        parent are passed to the initialization, unless a parameter is given as an
        explicit *keyword*-parameter.

        :param document_crumb: Extends the
                               :attr:`~cerberus.Validator.document_path`
                               of the child-validator.
        :type document_crumb: :class:`tuple` or :term:`hashable`
        :param schema_crumb: Extends the
                             :attr:`~cerberus.Validator.schema_path`
                             of the child-validator.
        :type schema_crumb: :class:`tuple` or hashable
        :param kwargs: Overriding keyword-arguments for initialization.
        :type kwargs: :class:`dict`

        :return: an instance of ``self.__class__``
        T�is_childrP�root_allow_unknown�root_require_all�
root_document�root_schemaNr-)rirrNr��toy_error_handlerrBrCrDrArXrLr\r]rM)r�document_crumb�schema_crumbrW�child_config�child_validators      r �_get_child_validatorz"BareValidator._get_child_validator;s��&�|�(�(�*�*�����F�#�#�#��}�	6�'+�L��$�,=�L��)�15�1C�L�-�.�/3�/?�L�+�,�,0�M�L��)�*.�+�L��'�(�$�.�8�8�<�8�8���!�,0�,>�O�)�)��n�e�4�4�
3�"0�!2��,0�,>��,O�O�)���*.�*:�O�'�'��l�E�2�2�
/� ,���*.�*:�\�*I�O�'��r"c���d�||�dd����}t||d��}|�#td�||�����|S)Nz_{0}_{1}� �_z/There's no handler for '{}' in the '{}' domain.)�format�replace�getattrr)r�domainr�
methodname�results     r �__get_rule_handlerz BareValidator.__get_rule_handlerjsh���&�&�v�t�|�|�C��/E�/E�F�F�
���z�4�0�0���>��� �&��v�.�.���
��
r"c�j�t|j��}t|j��}|D]�}t|d���D]}t	|j||z��|_� t|d���D]}t	|j||z��|_� |jr|�|j||����dS)a{
        Removes nodes by index from an errorpath, relatively to the basepaths of self.

        :param errors: A list of :class:`errors.ValidationError` instances.
        :param dp_items: A list of integers, pointing at the nodes to drop from
                         the :attr:`document_path`.
        :param sp_items: Alike ``dp_items``, but for :attr:`schema_path`.
        T)�reverseN)rgrLrM�sortedr�child_errors�_drop_nodes_from_errorpaths)rrF�dp_items�sp_items�dp_basedepth�sp_basedepthr�rks        r r�z)BareValidator._drop_nodes_from_errorpathsts����4�-�.�.���4�+�,�,���
	Y�
	Y�E��H�d�3�3�3�
�
��&:��'���)9�'�'��#�#��H�d�3�3�3�
�
��$8��%�|�a�'7�%�%��!�!��!�
Y��0�0��1C�X�x�X�X�X��
	Y�
	Yr"c��|�d��r.|dd�}|�d��r|jn|j}n|j}|�d��}|D]}||vrdS|�|i��}� |d|fS)a�
        Searches for a field as defined by path. This method is used by the
        ``dependency`` evaluation logic.

        :param path: Path elements are separated by a ``.``. A leading ``^``
                     indicates that the path relates to the document root,
                     otherwise it relates to the currently evaluated document,
                     which is possibly a subdocument.
                     The sequence ``^^`` at the start will be interpreted as a
                     literal ``^``.
        :type path: :class:`str`
        :returns: Either the found field name and its value or :obj:`None` for
                  both.
        :rtype: A two-value :class:`tuple`.
        �^rtN�.�NN���)�
startswithrDr��splitrR)r�path�context�parts�parts     r �
_lookup_fieldzBareValidator._lookup_field�s��� �?�?�3���	$�����8�D�'+���s�';�';�S�d�m�m��AS�G�G��m�G��
�
�3�����	,�	,�D��7�"�"�!�z�z��k�k�$��+�+�G�G��R�y�'�!�!r"c��t|t��r|St|t��r|j�|��SdS�N)r\rrrrR)rr�s  r r�z BareValidator._resolve_rules_set�sH���i��)�)�	:���
�	�9�
-�
-�	:��*�.�.�y�9�9�9��tr"c��t|t��r|St|t��r|j�|��SdSr�)r\rrrrR�rrAs  r r�zBareValidator._resolve_schema�sG���f�g�&�&�	4��M�
��	�
*�
*�	4��'�+�+�F�3�3�3��tr"c�8�|j�dd��S)a2
        If ``True`` unknown fields that are not defined in the schema will be ignored.
        If a mapping with a validation schema is given, any undefined field will be
        validated against its rules. Also see :ref:`allowing-the-unknown`.
        Type: :class:`bool` or any :term:`mapping`
        rBF�rirR�rs r rBzBareValidator.allow_unknown�����|�����7�7�7r"c��|js.t|ttf��st|d|i��||jd<dS)NrB)r�r\�boolrri�rrs  r rBzBareValidator.allow_unknown�sJ���
�	=��E�D�:J�3K�!L�!L�	=��T�O�U�#;�<�<�<�(-���_�%�%�%r"c�8�|j�dd��S)zw
        If ``True`` known fields that are defined in the schema will be required.
        Type: :class:`bool`
        rCFr�r�s r rCzBareValidator.require_all�s���|���
�u�5�5�5r"c��||jd<dS)NrC�rir�s  r rCzBareValidator.require_all�s��&+���]�#�#�#r"c�6�|�|j��S)z�
        The errors of the last processing formatted by the handler that is bound to
        :attr:`~cerberus.Validator.error_handler`.
        )rPrFr�s r r	zBareValidator.errors�s���!�!�$�,�/�/�/r"c�8�|j�dd��S)zm
        Whether to not process :obj:`None`-values in a document or not.
        Type: :class:`bool`
        rcFr�r�s r rcz BareValidator.ignore_none_values�s���|��� 4�e�<�<�<r"c��||jd<dS)Nrcr�r�s  r rcz BareValidator.ignore_none_values�s��-2���)�*�*�*r"c�8�|j�dd��S)z�
        ``True`` for child-validators obtained with
        :meth:`~cerberus.Validator._get_child_validator`.
        Type: :class:`bool`
        r�Fr�r�s r r�zBareValidator.is_child�s���|���
�E�2�2�2r"c�8�|j�dd��S)z/``True`` if the document is already normalized.�_is_normalizedFr�r�s r r�zBareValidator._is_normalized�s���|��� 0�%�8�8�8r"c��||jd<dS)Nr�r�r�s  r r�zBareValidator._is_normalized����).���%�&�&�&r"c�8�|j�dd��S)z�
        If ``True``, unknown fields will be deleted from the document unless a
        validation is called with disabled normalization. Also see
        :ref:`purging-unknown-fields`.
        Type: :class:`bool`
        rdFr�r�s r rdzBareValidator.purge_unknown�r�r"c��||jd<dS)Nrdr�r�s  r rdzBareValidator.purge_unknowns��(-���_�%�%�%r"c�8�|j�dd��S)z�
        If ``True``, fields declared as readonly will be deleted from the document
        unless a validation is called with disabled normalization.
        Type: :class:`bool`
        reFr�r�s r rezBareValidator.purge_readonly	s���|��� 0�%�8�8�8r"c��||jd<dS)Nrer�r�s  r rezBareValidator.purge_readonlyr�r"c�B�|j�d|j��S)z�
        The :attr:`~cerberus.Validator.allow_unknown` attribute of the first level
        ancestor of a child validator.
        r�)rirRrBr�s r r�z BareValidator.root_allow_unknowns ���|��� 4�d�6H�I�I�Ir"c�B�|j�d|j��S)z�
        The :attr:`~cerberus.Validator.require_all` attribute of the first level
        ancestor of a child validator.
        r�)rirRrCr�s r r�zBareValidator.root_require_alls ���|��� 2�D�4D�E�E�Er"c�B�|j�d|j��S)z~
        The :attr:`~cerberus.Validator.document` attribute of the first level ancestor
        of a child validator.
        r�)rirRrDr�s r r�zBareValidator.root_document&s���|������?�?�?r"c�B�|j�dt��S)zj
        The registry that holds referenced rules sets.
        Type: :class:`~cerberus.Registry`
        r)rirRrr�s r rz BareValidator.rules_set_registry.s���|��� 4�6H�I�I�Ir"c��||jd<dS)Nrr��r�registrys  r rz BareValidator.rules_set_registry6s��-5���)�*�*�*r"c�B�|j�d|j��S)z|
        The :attr:`~cerberus.Validator.schema` attribute of the first level ancestor of
        a child validator.
        r�)rirRrAr�s r r�zBareValidator.root_schema:s���|���
�t�{�;�;�;r"c��|jS)z�
        The validation schema of a validator. When a schema is passed to a method, it
        replaces this attribute.
        Type: any :term:`mapping` or :obj:`None`
        )�_schemar�s r rAzBareValidator.schemaBs���|�r"c��|�	d|_dS|jst|t��r	||_dSt||��|_dSr�)r�r�r\rr�s  r rAzBareValidator.schemaKsN���>��D�L�L�L�
�]�	:�j��1A�B�B�	:�!�D�L�L�L�+�D�&�9�9�D�L�L�Lr"c�B�|j�dt��S)zg
        The registry that holds referenced schemas.
        Type: :class:`~cerberus.Registry`
        r)rirRrr�s r rzBareValidator.schema_registryTs���|��� 1�?�C�C�Cr"c��||jd<dS)Nrr�r�s  r rzBareValidator.schema_registry\s��*2���&�'�'�'r"c��t|j��t|j��z}|rtd|z��t	|j��|jzS)zi
        The constraints that can be used for the 'type' rule.
        Type: A tuple of strings.
        zcThese types are defined both with a method and in the'types_mapping' property of this validator: %s)r>�
types_mapping�_types_from_methodsrr])rq�redundant_typess  r �typeszBareValidator.typesbsh���c�/�0�0�3�s�7N�3O�3O�O���	��A�CR�S�
�
�
�
�S�&�'�'�#�*A�A�Ar"c��tj��|_d|_tj��|_tj��|_t|��|_	|j
sd|_|�t||��|_
nB|j
�;t|jt ��ri|_nt%tj���|�t)tj���t|t ��s,t)tj�|�����|j�|��dS�NF)r	rErFrGrHrIrJrKrrDr�r�rrAr\rBrr�r�SCHEMA_ERROR_MISSINGr(�DOCUMENT_MISSING�DOCUMENT_FORMATr�rP�start)rrDrAs   r �__init_processingzBareValidator.__init_processingss���'�)�)��� ���#)�#;�#=�#=�� �!'�!7�!9�!9����X����
��}�	(�"'�D����*�4��8�8�D�K�K�
�[�
 ��$�,�g�6�6�
?�!����!�&�"=�>�>�>����� 7�8�8�8��(�G�,�,�	I��� 6� =� =�h� G� G�H�H�H��� � ��&�&�&�&�&r"c�|�|r2|D]-}	|j�|���#t$rY�*wxYwdSg|_dS)z�
        Drops rules from the queue of the rules that still need to be evaluated for the
        currently processed field. If no arguments are given, the whole queue is
        emptied.
        N)rS�remove�
ValueError)r�rulesrs   r �_drop_remaining_rulesz#BareValidator._drop_remaining_rules�st���	'��
�
����)�0�0��6�6�6�6��!�����D�����
�
�%'�D�!�!�!s�#�
0�0Fc���|�||��|�|j|j��|j�|��|jr|sdS|jS)a
        Returns the document normalized according to the specified rules of a schema.

        :param document: The document to normalize.
        :type document: any :term:`mapping`
        :param schema: The validation schema. Defaults to :obj:`None`. If not
                       provided here, the schema must have been provided at
                       class instantiation.
        :type schema: any :term:`mapping`
        :param always_return_document: Return the document, even if an error
                                       occurred. Defaults to: ``False``.
        :type always_return_document: :class:`bool`
        :return: A normalized copy of the provided mapping or :obj:`None` if an
                 error occurred during normalization.
        N)�_BareValidator__init_processing�!_BareValidator__normalize_mappingrDrArP�endrF)rrDrA�always_return_documents    r �
normalizedzBareValidator.normalized�sj�� 	
���x��0�0�0�� � �����<�<�<�����t�$�$�$��<�	!� 6�	!��4��=� r"c�4�t|t��r|�|��}|���}|D] }|�||��||<�!|�||��|jr|js|�||��|j	r|�
||��|�||��|�||��|�
||��|�||��d|_|S)NT)r\rr�rr��'_BareValidator__normalize_rename_fieldsrdrB�_normalize_purge_unknownre�(_BareValidator__normalize_purge_readonly�(_BareValidator__validate_readonly_fields�(_BareValidator__normalize_default_fields�_normalize_coerce�$_BareValidator__normalize_containersr��r�mappingrArs    r �__normalize_mappingz!BareValidator.__normalize_mapping�s+���f�i�(�(�	2��)�)�&�1�1�F��������	C�	C�E� �3�3�F�5�M�B�B�F�5�M�M��&�&�w��7�7�7���	;�d�&8�	;��)�)�'�6�:�:�:���	=��+�+�G�V�<�<�<�	
�'�'���8�8�8��'�'���8�8�8����w��/�/�/��#�#�G�V�4�4�4�"����r"c
��tj}|D]�}||vrSd||vrI|�||d|||||�dd��|��||<�Yt	|jt��rOd|jvrF|�|jd||||j�dd��|��||<��dS)��
        {'oneof': [
            {'type': 'callable'},
            {'type': 'list',
             'schema': {'oneof': [{'type': 'callable'},
                                  {'type': 'string'}]}},
            {'type': 'string'}
        ]}
        �coercer2FN)r	�COERCION_FAILED� _BareValidator__normalize_coercerRr\rBr)rr�rAr�rs     r r�zBareValidator._normalize_coerce�s����&���	�	�E�����8�v�e�}�#<�#<�!%�!8�!8��5�M�(�+���E�N��5�M�%�%�j�%�8�8��"�"������4�-�w�7�7�

��� 2�2�2�!%�!8�!8��&�x�0���E�N��&�*�*�:�u�=�=��"�"�����	�	r"c���t|t��r|�d|��}nht|t��rS|}|D]L}|�|||||��}t
j|j�|j	|fz��vrn�M|S	||��S#t$r4}|r|�$|�||t|����|cYd}~Sd}~wwxYw)N�normalize_coerce)
r\r� _BareValidator__get_rule_handlerrr�r	r�rI�fetch_errors_fromrL�	Exceptionr|�str)	r�	processorrrr2r�r�rl�es	         r �__normalize_coercez BareValidator.__normalize_coerce�s���i��+�+�	��/�/�0B�I�N�N�I�I�
�	�8�
,�
,�	��F��
�
���0�0��E�6�8�U�S�S���*��/�A�A��*�e�X�5�����
�E���M�	��9�U�#�#�#���	�	�	��
2������E�5�#�a�&�&�1�1�1��L�L�L�L�L�L�����	���s�
B!�!
C�+)C�C�Cc��|D�]U}t|�|d����}t||t��r�d|vr#|�||||d��d|vr#|�||||d��|td��zst|jt��r)	|�|||����#t$rY��wxYw��t||t��r��t||t��r8d|vr|�|||����:d|vr|�|||����WdS)Nr-�	keysrules�valuesrules)rBrdrArA�items)
r>rRr\r�/_BareValidator__normalize_mapping_per_keysrules�1_BareValidator__normalize_mapping_per_valuesrulesrB�,_BareValidator__normalize_mapping_per_schemar/rr�-_BareValidator__normalize_sequence_per_schema�,_BareValidator__normalize_sequence_per_items)rr�rArr�s     r �__normalize_containersz$BareValidator.__normalize_containerss����	P�	P�E���
�
�5�"�-�-�.�.�E��'�%�.�'�2�2�
P��%�'�'��:�:��w��u�
�k�(B����!�E�)�)��<�<��w��u�
�m�(D�����3�@������� 2�G�<�<����;�;�E�7�F�S�S�S�S��/������������G�E�N�I�6�6�
P���G�E�N�H�5�5�
P��u�$�$��8�8����P�P�P�P���%�%��7�7��w��O�O�O��9	P�	Ps�?C�
C$�#C$c
����t�fd�||D����}td�||D����}|�||df|���}|�|d���}|jr8|�|jgddg��|�|j��|D]�}|||kr�||||vrht
d	�d
�d�|j	|fzD����|�����|||||||<��|||||||<|||=��dS)
Nc3� �K�|]}|�fV��	dSr�r-)�.0�k�property_ruless  �r �	<genexpr>zBBareValidator.__normalize_mapping_per_keysrules.<locals>.<genexpr>!s(�����C�C�q��>�*�C�C�C�C�C�Cr"c3�K�|]}||fV��	dSr�r-�rrs  r rzBBareValidator.__normalize_mapping_per_keysrules.<locals>.<genexpr>"s&����8�8�A�!�Q��8�8�8�8�8�8r"r
�r�r�rAT�r�ru�zHNormalizing keys of {path}: {key} already exists, its value is replaced.r�c3�4K�|]}t|��V��dSr�)r�r�xs  r rzBBareValidator.__normalize_mapping_per_keysrules.<locals>.<genexpr>1s(����%T�%T��c�!�f�f�%T�%T�%T�%T�%T�%Tr")r��key)
r9r�r�rFr�r|rr��joinrL)	rrr�rrArD�	validatorr�rs	   `     r �!__normalize_mapping_per_keysrulesz/BareValidator.__normalize_mapping_per_keysrules s�����C�C�C�C�G�E�N�C�C�C�D�D���8�8����8�8�8�9�9���-�-� ��{�/C�F�.�
�
�	��%�%�h�t�%�L�L����	+��,�,�Y�->��Q��F�K�K�K��K�K�	�)�*�*�*��	&�	&�A��F�1�I�~�~���a�y�G�E�N�*�*��-�-3�V� �X�X�%T�%T�d�6H�E�8�6S�%T�%T�%T�T�T��.4�.�.����-4�E�N�1�,=����v�a�y�)�)�,3�E�N�1�,=����v�a�y�)��E�N�1�%�%�	&�	&r"c�>��t�fd�||D����}|�||df|���}|�||d���||<|jr9|�|jgdg��|�|j��dSdS)Nc3� �K�|]}|�fV��	dSr�r-)rr�value_ruless  �r rzDBareValidator.__normalize_mapping_per_valuesrules.<locals>.<genexpr>;s(�����@�@�A��;�'�@�@�@�@�@�@r"rrTrru)r9r�r�rFr�r|)rrr�r'rAr#s   `  r �#__normalize_mapping_per_valuesrulesz1BareValidator.__normalize_mapping_per_valuesrules:s�����@�@�@�@����@�@�@�A�A���-�-� ��}�/E�f�.�
�
�	�#�-�-��E�N�4�.�
�
������	+��,�,�Y�->��Q�C�H�H�H��K�K�	�)�*�*�*�*�*�	+�	+r"c�6�|�|i��}|s!t|jt��r|j}|�||df|�di��|�d|j��|�d|j��|�d|j�����}t||��}|�||d���}||��||<|j	r|�
|j	��dSdS)NrArBrdrC)r�r�rArBrdrCTr)rRr\rBrr�rdrCr4r�rFr|)rrr�rAr�r#�
value_type�result_values        r �__normalize_mapping_per_schemaz,BareValidator.__normalize_mapping_per_schemaFs���
�
�5�"�%�%���	'��D�$6��@�@�	'��&�E��-�-� ���*��9�9�X�r�*�*��)�)�O�T�5G�H�H��)�)�O�T�5G�H�H��	�	�-��1A�B�B�
.�
�
�	��'�%�.�)�)�
� �+�+�G�E�N�SW�+�X�X��#��L�1�1������	+��K�K�	�)�*�*�*�*�*�	+�	+r"c	�&���t��fd�tt|�����D�����td�t|���D����}|���df����}t|���}|�|d���}||�����|�<|jr9|�	|jgdg��|�
|j��dSdS)Nc3�8�K�|]}|��dfV��dS)rANr-)rrrrAs  ��r rz@BareValidator.__normalize_sequence_per_schema.<locals>.<genexpr>Zs1�����N�N�a�a����x�(�
)�N�N�N�N�N�Nr"c3�$K�|]\}}||fV��dSr�r-�rr�vs   r rz@BareValidator.__normalize_sequence_per_schema.<locals>.<genexpr>\s*����E�E�4�1�a��A��E�E�E�E�E�Er"rArTrru)r9�rangergrfr�r4r��valuesrFr�r|)rrr�rArDr#r*r�s ` `    r �__normalize_sequence_per_schemaz-BareValidator.__normalize_sequence_per_schemaXs$�����N�N�N�N�N�5��W�U�^�9L�9L�3M�3M�N�N�N�
�
���E�E�9�W�U�^�+D�+D�E�E�E�E�E���-�-� ��x�/@��.�
�
�	��'�%�.�)�)�
��%�%�h�t�%�L�L��#��F�M�M�O�O�4�4������	+��,�,�Y�->��Q�C�H�H�H��K�K�	�)�*�*�*�*�*�	+�	+r"c�Z�||d||}}t|��t|��krdStd�t|��D����}td�t|��D����}|�||df|���}t	||��}|�|d���}	||	�����||<|jr9|�|jgdg��|�	|j��dSdS)Nrc3�$K�|]\}}||fV��dSr�r-r0s   r rz?BareValidator.__normalize_sequence_per_items.<locals>.<genexpr>ks*����;�;�$�!�Q��1�v�;�;�;�;�;�;r"c3�$K�|]\}}||fV��dSr�r-r0s   r rz?BareValidator.__normalize_sequence_per_items.<locals>.<genexpr>ls*����=�=�4�1�a��A��=�=�=�=�=�=r"rTrru)
rgr9rfr�r4r�r3rFr�r|)
rrr�rAr�r3rDr#r*r�s
          r �__normalize_sequence_per_itemsz,BareValidator.__normalize_sequence_per_itemsgs5���u�
�g�.����v���u�:�:��V���$�$��F��;�;�)�E�*:�*:�;�;�;�<�<���=�=�9�V�+<�+<�=�=�=�=�=���-�-� ��w�/?��.�
�
�	��'�%�.�)�)�
��%�%�h�t�%�L�L��#��F�M�M�O�O�4�4������	+��,�,�Y�->��Q�C�H�H�H��K�K�	�)�*�*�*�*�*�	+�	+r"c�T���fd�|D��D]}|�|���|S)Nc�h��g|].}��|i���dd���,|��/S)r3F�rR�rr rAs  �r �
<listcomp>z<BareValidator.__normalize_purge_readonly.<locals>.<listcomp>ys<���U�U�U�A�F�J�J�q�"�,=�,=�,A�,A�*�e�,T�,T�U�a�U�U�Ur"�rZ�r�rArs ` r �__normalize_purge_readonlyz(BareValidator.__normalize_purge_readonlyws@���U�U�U�U��U�U�U�	�	�E��K�K�������r"c�T���fd�|D��D]}|�|���|S)�{'type': 'boolean'}c���g|]}|�v�|��	Sr-r-r<s  �r r=z:BareValidator._normalize_purge_unknown.<locals>.<listcomp>�s���<�<�<�A�A�V�O�O�a�O�O�Or"r>r?s ` r r�z&BareValidator._normalize_purge_unknown}sB���=�<�<�<��<�<�<�	�	�E��K�K�������r"c��t|��D]v}||vr/|�|||��|�|||���5t|jt
��r'd|jvr|�|||ji|���w|S)N�rename_handler)r]�_normalize_rename�_normalize_rename_handlerr\rBrr�s    r �__normalize_rename_fieldsz'BareValidator.__normalize_rename_fields�s����7�^�^�
	�
	�E������&�&�w���>�>�>��.�.�w���F�F�F�F��4�-�w�7�7�
�$��(:�:�:��.�.��e�T�%7�8�%������r"c�R�d||vr|||||d<||=dSdS)z{'type': 'hashable'}�renameNr-r�s    r rFzBareValidator._normalize_rename�s;���v�e�}�$�$�/6�u�~�G�F�5�M�(�+�,������%�$r"c��d||vrdS|�||d||dtj��}||kr||||<||=dSdS)r�rENF)r�r	�RENAMING_FAILED)rr�rAr�new_names     r rGz'BareValidator._normalize_rename_handler�ss���6�%�=�0�0��F��*�*��5�M�*�+�U�E�5�&�BX�
�
���u��� '���G�H��������r"c��������fd��D��D]+}���|d|�|���,dS)Nc3��K�|]8}|�v����|���d���4|V��9dS)r3N)r�rR)rr r�rArs  ���r rz;BareValidator.__validate_readonly_fields.<locals>.<genexpr>�sY�����
�
���G�|�|�� 7� 7��q�	� B� B� F� F�z� R� R�|�
��|�|�|�
�
r"r3)�_validate_readonlyr�s``` r �__validate_readonly_fieldsz(BareValidator.__validate_readonly_fields�sy�����
�
�
�
�
�
��
�
�
�	V�	V�E�

�#�#�F�5�M�*�$=�u�g�e�n�U�U�U�U�	V�	Vr"c�������fd��D��}	�fd�|D��}n#t$rt�wxYw|D]}|���|���t��}�fd�|D��}|r�|�d��}	|���|��ne#t$r|�|��YnDt$r8}|�	|tjt|����Yd}~nd}~wwxYwtt|����}	|	|vr(|D]#}|�	|tjd���$dS|�|	��|��dSdS)Nc�d��g|],}|�vs$�|��|�dd���*|��-S)Nr2Fr;)rr r�rAs  ��r r=z<BareValidator.__normalize_default_fields.<locals>.<listcomp>�sT���
�
�
��������
�"��q�	�
�
�j�%�8�8�#�	
�#�"�"r"c�(��g|]}d�|v�|��S)�defaultr-r<s  �r r=z<BareValidator.__normalize_default_fields.<locals>.<listcomp>�s(���"U�"U�"U��i�6�RS�9�>T�>T�1�>T�>T�>Tr"c�(��g|]}d�|v�|��S)�default_setterr-r<s  �r r=z<BareValidator.__normalize_default_fields.<locals>.<listcomp>�s/���&
�&
�&
��'7�6�!�9�'D�'D�A�'D�'D�'Dr"rz)Circular dependencies of default setters.)rhr/�_normalize_defaultr>rZ�_normalize_default_setter�KeyError�appendrr|r	�SETTING_DEFAULT_FAILEDr�hashr]rz)
rr�rA�empty_fields�fields_with_defaultr�known_fields_states�fields_with_default_setterr�fields_processing_states
 ``       r �__normalize_default_fieldsz(BareValidator.__normalize_default_fields�s'����
�
�
�
�
��
�
�
��	'�"U�"U�"U�"U�l�"U�"U�"U�����	'�	'�	'�&�&�	'����(�	<�	<�E��#�#�G�V�U�;�;�;�;�!�e�e��&
�&
�&
�&
�#�&
�&
�&
�"�)�	A�.�2�2�1�5�5�E�
J��.�.�w���F�F�F�F���
9�
9�
9�*�1�1�%�8�8�8�8�8��
J�
J�
J����E�6�#@�#�a�&�&�I�I�I�I�I�I�I�I�����
J����'+�5�1K�+L�+L�&M�&M�#�&�*=�=�=�7���E��K�K���5�C�����
��#�'�'�(?�@�@�@�')�	A�	A�	A�	A�	As&�"�4�B�D�	D�	.C<�<Dc�(�||d||<dS)z{'nullable': True}rUNr-r�s    r rXz BareValidator._normalize_default�s�����y�1�����r"c��d||vrI||d}t|t��r|�d|��}||��||<dSdS)zi
        {'oneof': [
            {'type': 'callable'},
            {'type': 'string'}
        ]}
        rW�normalize_default_setterN)r\rr)rr�rAr�setters     r rYz'BareValidator._normalize_default_setter�sh���v�e�}�,�,��E�]�#3�4�F��&�)�,�,�
U��0�0�1K�V�T�T��#�V�G�_�_�G�E�N�N�N�	-�,r"Tc��||_t��|_|�||��|r |�|j|j��|jD]_}|jr|j|��|j�|��}|�|�	||���J|�
|���`|js|�|j��|j�
|��t|j��S)aO
        Normalizes and validates a mapping against a validation-schema of defined rules.

        :param document: The document to normalize.
        :type document: any :term:`mapping`
        :param schema: The validation schema. Defaults to :obj:`None`. If not
                       provided here, the schema must have been provided at
                       class instantiation.
        :type schema: any :term:`mapping`
        :param update: If ``True``, required fields won't be checked.
        :type update: :class:`bool`
        :param normalize: If ``True``, normalize the document before validation.
        :type normalize: :class:`bool`

        :return: ``True`` if validation succeeds, otherwise ``False``. Check
                 the :func:`errors` property for a list of processing errors.
        :rtype: :class:`bool`
        )rNr>�_unrequired_by_excludesr�r�rDrArcrR�$_BareValidator__validate_definitions�'_BareValidator__validate_unknown_fields�(_BareValidator__validate_required_fieldsrPr�r�rF)rrDrArN�	normalizer�definitionss       r �validatezBareValidator.validate�s��&���'*�u�u��$����x��0�0�0��	A��$�$�T�]�D�K�@�@�@��]�	6�	6�E��&�
�4�=��+?�+G���+�/�/�%�0�0�K��&��+�+�K��?�?�?�?��.�.�u�5�5�5�5��{�	;��+�+�D�M�:�:�:�����t�$�$�$����%�%�%�%r"c�l�|�dd��}|j|i|��|jr|sdS|jS)z�
        Wrapper around :meth:`~cerberus.Validator.validate` that returns the normalized
        and validated document or :obj:`None` if validation failed.
        r�FN)rZrorFrD)rrVrWr�s    r �	validatedzBareValidator.validatedsO��
"(���,D�e�!L�!L����
�t�&�v�&�&�&��<�	!� 6�	!��4��=� r"c�`�|jr�|j|}t|jttf��rT|jrdnd}|�|||ji���}|||id���s|�|j��dSdSdS|�|tj
��dS)NrB�__allow_unknown__)r�rAF�rm)rBrDr\rrr�r�r|rFr	r�)rrrr�r#s     r �__validate_unknown_fieldsz'BareValidator.__validate_unknown_fields)s�����	5��M�%�(�E��$�,�w�	�.B�C�C�
3�37�-�X���EX�� �5�5�!-�u�d�>P�6Q�6���	�!�y�%���5�A�A�A�3��K�K�	� 1�2�2�2�2�2�
3�
3�3�3�
�K�K��v�3�4�4�4�4�4r"c������������fd�}�������j����fd��jD������fd��jD��������fd��D������_�jrA�j�d��}	||��}|rnn#t$rYnwxYw�j�A����dS)z3Validate a field's value against its defined rules.c�r����d|��}|��|d������S)Nro)rrR)rr#rnrrrs  ����r �
validate_rulez;BareValidator.__validate_definitions.<locals>.validate_rule;s:����/�/�
�D�A�A�I��9�[�_�_�T�4�8�8�%��G�G�Gr"c�.��g|]}|�vs	|�jv�|��Sr-)�mandatory_validations)rr rnrs  ��r r=z8BareValidator.__validate_definitions.<locals>.<listcomp>Bs;���
�
�
���K���1��(B�#B�#B�
�#B�#B�#Br"c3�$�K�|]
}|�v�|V��dSr�r-)rr �rules_queues  �r rz7BareValidator.__validate_definitions.<locals>.<genexpr>Gs6�����
�
��Q�k�5I�5I�A�5I�5I�5I�5I�
�
r"c3�>�K�|]}|�vr|�jvr|dv�|V��dS))rBrC�metarvN)�normalization_rules)rr r|rs  ��r rz7BareValidator.__validate_definitions.<locals>.<genexpr>JsW�����
�
����#�#���1�1�1��M�M�M�	
�N�M�M�M�
�
r"rN)	r�rD�priority_validationsrxrzrSrZr/r�)rrnrrxrr�r|rs```   @@r �__validate_definitionsz$BareValidator.__validate_definitions8s��������	H�	H�	H�	H�	H�	H�	H�	H��-�-�k�:�:���
�e�$��
�
�
�
�
��.�
�
�
��
	���
�
�
�
��1�
�
�
�	
�	
�	
�	���
�
�
�
�
� �
�
�
�	
�	
�	
�!,����#�	��(�,�,�Q�/�/�D�
�&��t�,�,�������'�
�
�
���
�����#�	�	
�"�"�$�$�$�$�$s�5
C�
C�Cz� {'oneof': [{'type': 'boolean'},
                       {'type': ['dict', 'string'],
                        'check_with': 'bulk_schema'}]} c�.��t|t��rWt|t��sBt�fd�|D����}|r#|�|t
j|��dSdS|�vr#|�|t
j|��dSdS)z{'type': 'container'}c3�$�K�|]
}|�v�|V��dSr�r-)rr �allowed_valuess  �r rz2BareValidator._validate_allowed.<locals>.<genexpr>ks-�����J�J�A�!�>�2I�2I�a�2I�2I�2I�2I�J�Jr"N)r\rrr]r|r	�UNALLOWED_VALUES�UNALLOWED_VALUE)rr�rr�	unalloweds `   r �_validate_allowedzBareValidator._validate_allowedhs�����e�X�&�&�	B�z�%��/K�/K�	B��J�J�J�J��J�J�J�J�J�I��
G����E�6�#:�I�F�F�F�F�F�
G�
G��N�*�*����E�6�#9�5�A�A�A�A�A�+�*r"c�|�t|t��ra	|�d|��}n;#t$r.|�d|��}t	dt
��YnwxYw|||��dSt|t��r|D]}|�|||���dS||||j��dS)r��
check_withr#ziThe 'validator' rule was renamed to 'check_with'. Please update your schema and method names accordingly.N)	r\rrrr�DeprecationWarningr�_validate_check_withr|)r�checksrr�
value_checkerr1s      r r�z"BareValidator._validate_check_withrs���f�i�(�(�	.�	
� $� 7� 7��f� M� M�
�
���
�
�
� $� 7� 7��V� L� L�
��@�&������
����
�M�%��'�'�'�'�'�
���
)�
)�	.��
;�
;���)�)�!�U�E�:�:�:�:�
;�
;�
�F�5�%���-�-�-�-�-s�.�5A&�%A&c�6�t|t��sdSt|t��rt|t��rt|f��}nt|��}|t|��z
}|r#|�|t
j|��dSdS)z{'empty': False }N)r\rrr>r|r	�MISSING_MEMBERS)r�expected_valuesrr�missing_valuess     r �_validate_containsz BareValidator._validate_contains�s����%��*�*�	��F��/�8�4�4�	3�
��Y�9
�9
�	3�"�?�"4�5�5�O�O�!�/�2�2�O�(�3�u�:�:�5���	G��K�K��v�5�~�F�F�F�F�F�	G�	Gr"c�j�t|t��st|ttf��s|f}t|t��r|�||��n+t|t��r|�||��|j�|j	|dfz��	�dSdS)zD{'type': ('dict', 'hashable', 'list'), 'check_with': 'dependencies'}�dependenciesNT)
r\rrrr�._BareValidator__validate_dependencies_sequence�-_BareValidator__validate_dependencies_mappingrI�fetch_node_fromrM)rr�rrs    r �_validate_dependenciesz$BareValidator._validate_dependencies�s����l�I�.�.�	+�j��8�W�-�7
�7
�	+�)�?�L��l�H�-�-�	F��1�1�,��F�F�F�F�
��g�
.�
.�	F��0�0��u�E�E�E�
�$�4�4�� �E�>�#:�:�
�
��
�
�4�
�
r"c�z�d}i}|���D]k\}}t|t��rt|t��r|g}|�|��\}}||vr|dz
}�T|�||i���l|t
|��kr#|�|tj	|��dSdS)Nrrt)
rr\rrr�rNrgr|r	�DEPENDENCIES_FIELD_VALUE)	rr�r�validated_dependencies_counter�
error_info�dependency_name�dependency_values�wanted_field�wanted_field_values	         r �__validate_dependencies_mappingz-BareValidator.__validate_dependencies_mapping�s���)*�&��
�2>�2D�2D�2F�2F�
	I�
	I�.�O�.��/��:�:�
8�j�!�9�?�?�
8�&7�$7�!�/3�/A�/A�/�/R�/R�,�L�,�!�%6�6�6�.�!�3�.�.��!�!�?�4F�"G�H�H�H�H�)�S��->�->�>�>��K�K��v�>�
�K�K�K�K�K�?�>r"c��|D]>}|�|��d�!|�|tj|���?dS)Nr)r�r|r	�DEPENDENCIES_FIELD)rr�r�
dependencys    r � __validate_dependencies_sequencez.BareValidator.__validate_dependencies_sequence�sR��&�	J�	J�J��!�!�*�-�-�a�0�8����E�6�#<�j�I�I�I��	J�	Jr"c	���t|t��rRt|��dkrA|�ddddddd��|s&|�|t
j��d	Sd	Sd	Sd	S)
rBr�allowed�	forbiddenr�	minlength�	maxlength�regexr�N)r\rrgr�r|r	�EMPTY_NOT_ALLOWED)rr5rrs    r �_validate_emptyzBareValidator._validate_empty�s����e�U�#�#�	=��E�
�
�a����&�&��������
�
�
��
=����E�6�#;�<�<�<�<�<�	=�	=���
=�
=r"c���t|t��r|g}�j|�d�j��r�j�|��|D]K}|�jvr@�j|�d�j��r�j�|���Lt�fd�|D����rBd�d�|D����}��	|tj|��dSdS)z>{'type': ('hashable', 'list'), 'schema': {'type': 'hashable'}}rvc3�*�K�|]
}|�jvV��dSr�)rD)r�excluded_fieldrs  �r rz3BareValidator._validate_excludes.<locals>.<genexpr>�s*�����U�U�>�~���.�U�U�U�U�U�Ur"z, c3�@K�|]}d�|��V��dS)z'{0}'N)r�)rrs  r rz3BareValidator._validate_excludes.<locals>.<genexpr>�s?����&�&�*/����u�%�%�&�&�&�&�&�&r"N)r\r
rArRrCrirz�anyr"r|r	�EXCLUDES_FIELD)r�excluded_fieldsrrr��
exclusion_strs`     r �_validate_excludesz BareValidator._validate_excludes�s6����o�x�0�0�	0�.�/�O��;�u��!�!�*�d�.>�?�?�	4��(�,�,�U�3�3�3�-�	A�	A�N����,�,���U�1C�1G�1G��D�,�2�2�,��,�0�0��@�@�@���U�U�U�U�_�U�U�U�U�U�	E� �I�I�&�&�3B�&�&�&���M�
�K�K��v�4�m�D�D�D�D�D�		E�	Er"c�N�t|t��rht|t��sSt|��t|��z}|r0|�|t
jt|����dSdS||vr#|�|t
j|��dSdS)z{'type': 'list'}N)	r\rrr>r|r	�FORBIDDEN_VALUESr<�FORBIDDEN_VALUE)r�forbidden_valuesrrr�s     r �_validate_forbiddenz!BareValidator._validate_forbidden�s����e�X�&�&�	B�z�%��/K�/K�	B��E�
�
�S�)9�%:�%:�:�I��
M����E�6�#:�D��O�O�L�L�L�L�L�
M�
M��(�(�(����E�6�#9�5�A�A�A�A�A�)�(r"c��t|��t|��kr>|�|tjt|��t|����dSt	d�t|��D����}|�||df|���}|t	d�t|��D����|jd���s(|�|tj|j	��dSdS)z'{'type': 'list', 'check_with': 'items'}c3�$K�|]\}}||fV��dSr�r-)rrk�
definitions   r rz0BareValidator._validate_items.<locals>.<genexpr>�s;������$1�A�z��J�������r"rrc3�$K�|]\}}||fV��dSr�r-)rrkrs   r rz0BareValidator._validate_items.<locals>.<genexpr>s*����B�B�H�A�u�a��Z�B�B�B�B�B�Br"F�rNrmN)
rgr|r	�ITEMS_LENGTHr9rfr�rN�	BAD_ITEMSrF)rrrr3rAr#s      r �_validate_itemszBareValidator._validate_items�s���u�:�:��V���$�$��K�K��v�2�C��J�J��F���L�L�L�L�L����5>�u�5E�5E������F��1�1�$�#�W�-��2���I�
�9��B�B�	�&�0A�0A�B�B�B�B�B��{�����
H�
���E�6�#3�Y�5F�G�G�G�G�G�
H�
Hr"c��d}tj��}t|��D]�\}}||���i}	dD]7}
|
|	|vr+|
|j|vr|j||
|	||
<�8d|	|vr|j|	|d<|�|||f|	d���}||j|jd���r|dz
}��|�	|j
gd	g��|�|j
����||fS)
zl
        Validates value against all definitions and logs errors according to the
        operator.
        r)rBr4rBT)r�rArBFr�rt�)r	rErfrrArBr�rDrNr�rFrx)r�operatorrnrr�
valid_counterrFrkr�rArr#s            r �__validate_logicalz BareValidator.__validate_logicalsF��
�
��"�$�$��&�{�3�3�	2�	2�M�A�z��Z�_�_�.�.�/�F�1�
C�
C���v�e�}�,�,����U�9K�1K�1K�*.�+�e�*<�T�*B�F�5�M�$�'���f�U�m�3�3�15�1C��u�
�o�.��1�1�#�X�q�1�&�PT�2���I��y���t�{�e�L�L�L�
2���"�
�
��0�0��1B�B���L�L�L����y�0�1�1�1�1��g�%�%r"c	��|�d|||��\}}|dkr2|�|tj||t	|����dSdS)z${'type': 'list', 'logical': 'anyof'}�anyofrtN)� _BareValidator__validate_logicalr|r	�ANYOFrg�rrnrr�validsrFs      r �_validate_anyofzBareValidator._validate_anyof'sY���1�1�'�;��u�U�U�����A�:�:��K�K��v�|�W�f�c�+�>N�>N�O�O�O�O�O��:r"c	���|�d|||��\}}|t|��kr2|�|tj||t|����dSdS)z${'type': 'list', 'logical': 'allof'}�allofN)r�rgr|r	�ALLOFr�s      r �_validate_allofzBareValidator._validate_allof-sd���1�1�'�;��u�U�U�����C��$�$�$�$��K�K��v�|�W�f�c�+�>N�>N�O�O�O�O�O�%�$r"c	��|�d|||��\}}|dkr2|�|tj||t	|����dSdS)z%{'type': 'list', 'logical': 'noneof'}�noneofrN)r�r|r	�NONEOFrgr�s      r �_validate_noneofzBareValidator._validate_noneof3sZ���1�1�(�K��PU�V�V�����A�:�:��K�K��v�}�g�v�s�;�?O�?O�P�P�P�P�P��:r"c	��|�d|||��\}}|dkr2|�|tj||t	|����dSdS)z${'type': 'list', 'logical': 'oneof'}�oneofrtN)r�r|r	�ONEOFrgr�s      r �_validate_oneofzBareValidator._validate_oneof9sY���1�1�'�;��u�U�U�����Q�;�;��K�K��v�|�W�f�c�+�>N�>N�O�O�O�O�O��;r"c�z�	||kr"|�|tj��dSdS#t$rYdSwxYw�z{'nullable': False }N)r|r	�	MAX_VALUErh)r�	max_valuerrs    r �
_validate_maxzBareValidator._validate_max?�Y��	��y� � ����E�6�#3�4�4�4�4�4�!� ���	�	�	��D�D�	�����&,�
:�:c�z�	||kr"|�|tj��dSdS#t$rYdSwxYwr�)r|r	�	MIN_VALUErh)r�	min_valuerrs    r �
_validate_minzBareValidator._validate_minGr�r�c��t|t��rCt|��|kr2|�|tjt|����dSdSdS�z{'type': 'integer'}N)r\rrgr|r	�
MAX_LENGTH)r�
max_lengthrrs    r �_validate_maxlengthz!BareValidator._validate_maxlengthO�Y���e�X�&�&�	>�3�u�:�:�
�+B�+B��K�K��v�0�#�e�*�*�=�=�=�=�=�	>�	>�+B�+Br"�c��t|t��rCt|��|kr2|�|tjt|����dSdSdSr�)r\rrgr|r	�
MIN_LENGTH)r�
min_lengthrrs    r �_validate_minlengthz!BareValidator._validate_minlengthVr�r"c��|�I|s |�|tj��|�dddddddd	d
ddd
ddddd��dSdS)rBNr�r�r�r5r�rr
�min�maxr�r�r�r�r�rAr4r)r|r	�NOT_NULLABLEr�)rr2rrs    r �_validate_nullablez BareValidator._validate_nullable[s����=��
8����E�6�#6�7�7�7��&�&������������������#
�
�
�
�
��=r"c	���t|t��r�|�||dft�fd�|���D�������}|td�|���D����d���sH|�|jgddg��|�|tj	|j��d	Sd	Sd	S)
��
        {'type': ['dict', 'string'],
         'check_with': 'bulk_schema',
         'forbidden': ['rename', 'rename_handler']}
        r
c3� �K�|]}|�fV��	dSr�r-�rrrAs  �r rz4BareValidator._validate_keysrules.<locals>.<genexpr>~s'�����?�?�Q�a��[�?�?�?�?�?�?r"rc3�K�|]}||fV��	dSr�r-rs  r rz4BareValidator._validate_keysrules.<locals>.<genexpr>�s&����"@�"@�a�A�q�6�"@�"@�"@�"@�"@�"@r"FrtrurN)
r\rr�r9�keysr�rFr|r	�	KEYSRULES)rrArrr#s `   r �_validate_keysrulesz!BareValidator._validate_keysrulests�����e�W�%�%�	H��1�1�$�#�[�1��?�?�?�?�%�*�*�,�,�?�?�?�@�@�2���I�
�9�T�"@�"@�5�:�:�<�<�"@�"@�"@�A�A�U�S�S�S�
H��0�0��1B�B��A��O�O�O����E�6�#3�Y�5F�G�G�G�G�G�	H�	H�
H�
Hr"c��|ru|js |�|tj��tj|j�|j|fz��v}|jr|r|���dSdSdSdS)rBN)r�r|r	�READONLY_FIELDrIrrLr�)rr3rr�	has_errors     r rPz BareValidator._validate_readonly�s����
	-��&�
:����E�6�#8�9�9�9�
�%��+�=�=��&�%��1����
��"�
-�y�
-��*�*�,�,�,�,�,�
	-�
	-�
-�
-�
-�
-r"c��t|t��sdS|�d��s|dz
}tj|��}|�|��s"|�|tj��dSdS)z{'type': 'string'}N�$)	r\r�endswith�re�compile�matchr|r	�REGEX_MISMATCH)r�patternrr�re_objs     r �_validate_regexzBareValidator._validate_regex�s����%��+�+�	��F�����$�$�	��s�N�G���G�$�$���|�|�E�"�"�	6��K�K��v�4�5�5�5�5�5�	6�	6r"z {'type': 'boolean'} c�D���	t�fd��j���D����}n.#t$r!�jr�jddkrt��wxYw|�jz}|t��fd��D����z
}|D]"}��|tj
���#�jrbt�fd��D����}�j�|��r/�j|z
D]&}��|tj
���#dSdSdS)zy
        Validates that required fields are not missing.

        :param document: The document being validated.
        c3��K�|]9\}}��|���d�j��du�5|V��:dS)rvTN)r�rRrC)rrr�rs   �r rz;BareValidator.__validate_required_fields.<locals>.<genexpr>�sl�������%�E�:��*�*�:�6�6�:�:�:�t�GW�X�X����������r"r�rAc3�T�K�|]"}��|����j�|V��#dSr�)rRrc)rrrDrs  ��r rz;BareValidator.__validate_required_fields.<locals>.<genexpr>�sI�����!
�!
���|�|�E�"�"�.�d�6M�.�
�.�.�.�.�!
�!
r"c3�F�K�|]}��|���|V��dSr�r;)rrrDs  �r rz;BareValidator.__validate_required_fields.<locals>.<genexpr>�s4�����X�X�5����U�8K�8K�8W��8W�8W�8W�8W�X�Xr"N)r>rAr�AttributeErrorr�rMr/rir|r	�REQUIRED_FIELD�
isdisjoint)rrDrv�missingr�fieldss``    r �__validate_required_fieldsz(BareValidator.__validate_required_fields�s�����	������)-��):�):�)<�)<������H�H���	�	�	��}�
��!1�"�!5��!A�!A�*�*��		����
	�D�0�0���S�!
�!
�!
�!
�!
�!�!
�!
�!
�
�
�
���	6�	6�E��K�K��v�4�5�5�5�5��'�	>��X�X�X�X�H�X�X�X�X�X�F��+�6�6�v�>�>�
>�!�9�F�B�>�>�E��K�K��v�'<�=�=�=�=�		>�	>�
>�
>�>�>s	�27�+A"c���|�dSt|t��r.t|t��s|�|||��dSt|t��r|�|||��dSdS)z�
        {'type': ['dict', 'string'],
         'anyof': [{'check_with': 'schema'},
                   {'check_with': 'bulk_schema'}]}
        N)r\rr�(_BareValidator__validate_schema_sequencer�'_BareValidator__validate_schema_mapping)rrArrs    r �_validate_schemazBareValidator._validate_schema�s����>��F��e�X�&�&�	A�z�%��/K�/K�	A��+�+�E�6�5�A�A�A�A�A�
��w�
'�
'�	A��*�*�5�&�%�@�@�@�@�@�	A�	Ar"c
���|�|��}|�|j|��}|�||df||�d|j��|�d|j�����}	|||jd���s(|�|tj
|j��dSdS#t$r"|�|tj
���wxYw)NrArBrC)r�r�rArBrCFr�)r�r�rAr�rRrBrCrNr|r	�MAPPING_SCHEMArFr/�BAD_TYPE_FOR_SCHEMA)rrrAr�field_rulesr#s      r �__validate_schema_mappingz'BareValidator.__validate_schema_mapping�s���%�%�f�-�-���-�-�d�k�%�.@�A�A���-�-� ���*��%�/�/�/�4�;M�N�N�#���
�t�7G�H�H�.�
�
�	�	��9�U�4�;�%�H�H�H�
M����E�6�#8�)�:K�L�L�L�L�L�
M�
M��#�	�	�	��K�K��v�9�:�:�:��	���s�9C�,C.c���t�fd�tt|����D�����|�||df�|j���}|td�t|��D����|jd���|jrE|�|jgdg��|�	|tj|j��dSdS)Nc3� �K�|]}|�fV��	dSr�r-)rrkrAs  �r rz;BareValidator.__validate_schema_sequence.<locals>.<genexpr>�s'�����>�>�q��6�{�>�>�>�>�>�>r"rA)r�r�rArBc3�$K�|]\}}||fV��dSr�r-)rrkr1s   r rz;BareValidator.__validate_schema_sequence.<locals>.<genexpr>�s*����6�6�T�Q��1�a�&�6�6�6�6�6�6r"Fr�ru)r9r2rgr�rBrfrNrFr�r|r	�SEQUENCE_SCHEMA)rrrArr#s  `  r �__validate_schema_sequencez(BareValidator.__validate_schema_sequence�s�����>�>�>�>�E�#�e�*�*�,=�,=�>�>�>�?�?���-�-� ���*���,�	.�
�
�	�	�	��6�6�Y�u�%5�%5�6�6�6�7�7��;��	
�	
�	
�	
���	J��,�,�Y�->��Q�C�H�H�H��K�K��v�5�y�7H�I�I�I�I�I�	J�	Jr"c��|sdSt|t��r|fn|}|D]p}|j�|��}|�,t||j��ot||j��}n!|�d|��}||��}|rdS�q|�|tj	��|�
��dS)zM
        {'type': ['string', 'list'],
         'check_with': 'type'}
        N�
validate_type)r\rr�rR�included_types�excluded_typesrr|r	�BAD_TYPEr�)	r�	data_typerrr��_type�type_definition�matched�type_handlers	         r �_validate_typezBareValidator._validate_type�s���
�	��F� *�9�i� @� @�O����i���	�	�E�#�0�4�4�U�;�;�O��*�$��?�9���L�$�U�O�,J�K�K�K��� $�6�6���N�N��&�,�u�-�-���
����
�	
���E�6�?�+�+�+��"�"�$�$�$�$�$r"c�^��|df}t|t��r�|�||t�fd�|D�������}|||jd���|jrG|�|jgdg��|�|tj	|j��dSdSdS)r�rc3� �K�|]}|�fV��	dSr�r-r�s  �r rz6BareValidator._validate_valuesrules.<locals>.<genexpr>%s'�����7�7�A�Q��K�7�7�7�7�7�7r"rFr�ruN)
r\rr�r9rNrFr�r|r	�VALUESRULES)rrArrr�r#s `    r �_validate_valuesrulesz#BareValidator._validate_valuesruless�����}�-���e�W�%�%�		J��1�1�$�)��7�7�7�7��7�7�7�7�7�2���I�

�I�e�D�K�5�A�A�A�A�� �
J��0�0��1B�B���L�L�L����E�6�#5�y�7H�I�I�I�I�I�		J�		J�
J�
Jr"r�r�r�)NFT)rr*r+r,r#rzr�r�bytes�	bytearrayr�rrrrrr:r
rr>r�rorU�staticmethodrOrQ�classmethodrrr|r�rr�r�r�r��propertyrBrgrCr	rcr�r�rdrer�r�r�rr�rArrr�r�r�r�r�r�r�r�r
rrrrr�r�r�rFrGr�r�rXrYro�__call__rqrkrjr&�_validate_allow_unknownr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��_validate_metar�r�r�rPr�_validate_required�_validate_require_allrlrrrr/r3�
__classcell__�rXs@r r1r1;s��������-�-�^*���
E���
!�.��E�9�+=�r�B�B�!�>�)�d�W�b�9�9�#�^�K�)��	�|�L�L���v��w��3�3�"�N�:��{�B�?�?���v��z�2�6�6����%��)<�b�A�A�!�>�)�j�]�B�?�?���v��{�Y�L�A�A� �.��J��+>���H�H��~�e�c�V�R�0�0� �.��I�<��<�<�
�
�M���S�U�U�N��
1.�1.�1.�1.�1.�f�
9�
9��\�
9�#�#�#�(�#�#��[�#�O-�O-�O-�b-�-�-�-�^���Y�Y�Y�."�"�"�<�������8�8��X�8���.�.���.�
�6�6��X�6���,�,���,��0�0��X�0��=�=��X�=���3�3���3��3�3��X�3��9�9��X�9���/�/���/��8�8��X�8���.�.���.��9�9��X�9���/�/���/��J�J��X�J��F�F��X�F��@�@��X�@��J�J��X�J���6�6���6��<�<��X�<�����X���]�:�:��]�:��D�D��X�D���3�3���3�
�B�B���B� '�'�'�'�,
'�
'�
'�"!�!�!�!�0���,���B���0P�P�P�>&�&�&�4
+�
+�
+�+�+�+�$
+�
+�
+�+�+�+� ����\��
����\�����������&V�V�V�)A�)A�)A�V2�2�2�-�-�-�(&�(&�(&�(&�T�H�
!�
!�
!�
5�
5�
5�%%�%%�%%�T8�7�	;����B�B�B�.�.�.�8G�G�G� ���(L�L�L�$J�J�J�

=�
=�
=�E�E�E�,B�B�B�H�H�H�(&�&�&�6P�P�P�P�P�P�Q�Q�Q�P�P�P�������>�>�>�
/�.�r�2�2�N�>�>�>�
���2H�H�H� -�-�-�"6�6�6�3�2�3N�O�O��5�5�6Q�R�R��">�">�">�HA�A�A����"J�J�J�$ %� %� %�DJ�J�J�J�J�J�Jr"r1z7The rule's arguments are validated against this schema:c�2��eZdZdZ�fd�Z�fd�Zd�Z�xZS)�InspectedValidatorzMetaclass for all validatorsc���d|dvr.|d�d|ddji��tt|��j|g|�R�S)Nr#rurtr)rNr#rTrA�__new__)rqrVrXs  �r rCzInspectedValidator.__new__3s^����D��G�#�#���G�N�N�I�t�A�w�q�z�'9�:�;�;�;�5�u�'��-�-�5�c�A�D�A�A�A�Ar"c�����fd�}tt���j|�dic�_�_|d��D]^}|�d��r'�xj|t
d��d�fz
c_�>��d|z���j|<�_�jrtdt��td�|d��D����td	�|d
��D����z�_�jdd}�jx|dd
ddd<|dd<d��jD��D]}d�j|d<�ddic�_
�_�_|d��D]�}|�d��r'�xj
|t
d��d�fz
c_
�>|�d��r'�xj|t
d��d�fz
c_�z��d|z���j|<��dD]B}�j|d}�j
x|dd
ddd<|dd<�C�j�jdddd<i�_�j��j���j��j��dS)Nc�V���t�fd�t���D����S)Nc3��K�|]9}|�d�zdz���|t���dzd�V��:dS)r�ruN)r�rg)rr �prefixs  �r rzNInspectedValidator.__init__.<locals>.attributes_with_prefix.<locals>.<genexpr>:sg���������<�<��f��s� 2�3�3���#�f�+�+��/�#�#�$������r")r]�dir)rGrqs`�r �attributes_with_prefixz;InspectedValidator.__init__.<locals>.attributes_with_prefix9sB����������S��������
r"r-ro�type_�
_validate_z}Methods for type testing are deprecated, use TypeDefinition and the 'types_mapping'-property of a Validator-instance instead.c3�K�|]}|V��dSr�r-rs  r rz.InspectedValidator.__init__.<locals>.<genexpr>Vs"����M�M�1�Q�M�M�M�M�M�Mr"r�c3�K�|]}|V��dSr�r-rs  r rz.InspectedValidator.__init__.<locals>.<genexpr>Vs;����V
�V
��A�V
�V
�V
�V
�V
�V
r"r#r�rtrAr�ruc3�&K�|]}|dk�|V��
dS)r2Nr-rs  r rz.InspectedValidator.__init__.<locals>.<genexpr>\s&����M�M�1�Q�*�_�_�Q�_�_�_�_�M�Mr"Trvrm�coerce_�default_setter_�_normalize_)r�rErW)rTrArUr��validation_rulesr�rg�$_InspectedValidator__get_rule_schemarr�r]�checkersrz�coercers�default_settersrr�rN)rqrVrI�	attributer rrXs`     �r rUzInspectedValidator.__init__8sl����	�	�	�	�	�	0�� �#�&�&�/��6�6�8:�B�5����!5�/�/�
�;�;�	�	�I��#�#�G�,�,�
��'�'�I�c�'�l�l�n�n�,E�+G�G�'�'�'�25�2G�2G� �9�,�3�3��$�Y�/�/�
�"�	���#�	
�
�
��M�M�(>�(>�|�(L�(L�M�M�M�M�M�PU�V
�V
�-�-�k�:�:�V
�V
�V
�Q
�Q
�
���
� ��.�w�7��BE�,�N��!��X��w���"�9�-��!��Y��M�M�� 9�M�M�M�	:�	:�D�59�C� ��&�z�2�2�EG��R�B���c�)�3�+B�/�/��<�<�	�	�I��#�#�I�.�.�
�����3�y�>�>�+;�+;�!<� >�>�����%�%�&7�8�8�
��#�#�	�#�6G�2H�2H�2J�2J�(K�'M�M�#�#�#�58�5J�5J�!�I�-�6�6��'�	�2�2�1�	S�	S�D��'��-�g�6�A�FI�l�R�A�a�D��N�7�#�A�&�y�1�A�a�D��O�O�
��	�� 0�1�'�:�1�=��	
���	��	����-�.�.�.��	����0�1�1�1�1�1r"c�^�t||��j}|�i}n^t|vr |�t��d}	t	|�����}n#t$ri}YnwxYw|s2|dkr,td|�dd��dz��|S)Nrtr;z>No validation schema is defined for the arguments of rule '%s'r�rur�)r�r#�RULE_SCHEMA_SEPARATORr�r�striprr)rq�method_name�	docstringr�s    r �__get_rule_schemaz$InspectedValidator.__get_rule_schemaus����C��-�-�5�	����F�F�$�	�1�1�%�O�O�,A�B�B�1�E�	�
�%�i�o�o�&7�&7�8�8�����
�
�
�����
�����	�+�)9�9�9���$�*�*�3��2�2�2�6�7�
�
�
�
�
s�!A'�'A6�5A6)r*r+r,r#rCrUrSr>r?s@r rArA0sl�������&�&�B�B�B�B�B�
;2�;2�;2�;2�;2�z������r"rA�	Validator)*�
__future__r�astrrrrr�warningsr�cerberusr	�cerberus.platformr
rrr
rrrr�cerberus.schemarrrr�cerberus.utilsrrr�ToyErrorHandlerr�r&rr(r/�objectr1rYr4rAr^r-r"r �<module>rhsI��&�&�&�&�&�&�������������#�#�#�#�#�#�#�#�	�	�	�	�������������	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�������������X�W�W�W�W�W�W�W�W�W�*�F�*�,�,��

�

�

�	�	�	�	�	�I�	�	�	�	�	�	�	�	�9�	�	�	�oJ�oJ�oJ�oJ�oJ�F�oJ�oJ�oJ�d/R��W�W�W�W�W��W�W�W�t
��{�]�,<�b�A�A�	�	�	r"