o
    $6dx&                  
   @  s  U d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
mZmZmZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZ dd
lmZ ddlmZ dZe
rG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"eeeee e!ej#ej$ej%ej&f	 Z'ee"ej(f Z)ee*eeef e+eef ee f Z,de-d< ede'e,Z.edej(e"e,Z/neZ0ddddddd;d,d-Z1ed.d/d<d3d4Z2ed.d/d=d5d4Z2ed.d/d>d7d4Z2dddd8d?d:d4Z2dS )@zCOld `@validator` and `@root_validator` function validators from V1.    )annotations)partialpartialmethod)FunctionType)TYPE_CHECKINGAnyCallableTypeVarUnionoverload)warn)LiteralProtocol	TypeAlias   )_decorators_decorators_v1)PydanticUserError)PydanticDeprecatedSince20zQ`allow_reuse` is deprecated and will be ignored; it should no longer be necessaryc                   @     e Zd ZdddZdS )	_OnlyValueValidatorClsMethod!_OnlyValueValidatorClsMethod__clsr   #_OnlyValueValidatorClsMethod__valuereturnc                 C     d S N )selfr   r   r   r   {C:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pydantic/deprecated/class_validators.py__call__      z%_OnlyValueValidatorClsMethod.__call__N)r   r   r   r   r   r   __name__
__module____qualname__r   r   r   r   r   r          r   c                   @     e Zd Zd
ddZd	S )_V1ValidatorWithValuesClsMethod$_V1ValidatorWithValuesClsMethod__clsr   &_V1ValidatorWithValuesClsMethod__valuevaluesdict[str, Any]r   c                 C  r   r   r   )r   r(   r)   r*   r   r   r   r      r    z(_V1ValidatorWithValuesClsMethod.__call__N)r(   r   r)   r   r*   r+   r   r   r!   r   r   r   r   r'      r%   r'   c                   @  r&   )%_V1ValidatorWithValuesKwOnlyClsMethod*_V1ValidatorWithValuesKwOnlyClsMethod__clsr   ,_V1ValidatorWithValuesKwOnlyClsMethod__valuer*   r+   r   c                C  r   r   r   )r   r-   r.   r*   r   r   r   r      r    z._V1ValidatorWithValuesKwOnlyClsMethod.__call__N)r-   r   r.   r   r*   r+   r   r   r!   r   r   r   r   r,      r%   r,   c                   @  r   )	_V1ValidatorWithKwargsClsMethod$_V1ValidatorWithKwargsClsMethod__clsr   kwargsr   c                 K  r   r   r   )r   r0   r1   r   r   r   r   "   r    z(_V1ValidatorWithKwargsClsMethod.__call__N)r0   r   r1   r   r   r   r!   r   r   r   r   r/   !   r%   r/   c                   @  r&   )(_V1ValidatorWithValuesAndKwargsClsMethod-_V1ValidatorWithValuesAndKwargsClsMethod__clsr   r*   r+   r1   r   c                 K  r   r   r   )r   r3   r*   r1   r   r   r   r   &   r    z1_V1ValidatorWithValuesAndKwargsClsMethod.__call__N)r3   r   r*   r+   r1   r   r   r   r!   r   r   r   r   r2   %   r%   r2   c                   @  s   e Zd Zd	ddZdS )
_V1RootValidatorClsMethod_V1RootValidatorClsMethod__clsr   !_V1RootValidatorClsMethod__values"_decorators_v1.RootValidatorValuesr   c                 C  r   r   r   )r   r5   r6   r   r   r   r   *   s   z"_V1RootValidatorClsMethod.__call__N)r5   r   r6   r7   r   r7   r!   r   r   r   r   r4   )   r%   r4   r   _PartialClsOrStaticMethod_V1ValidatorType_V1RootValidatorFunctionTypeFN)pre	each_itemalwayscheck_fieldsallow_reuse__fieldstrfieldsr;   boolr<   r=   r>   bool | Noner?   r   .Callable[[_V1ValidatorType], _V1ValidatorType]c                  s   |du r	t tt t| gR td trtdddtdd D s-tdd	dt d
tdd |du r:dndd fdd}|S )a  Decorate methods on the class indicating that they should be used to validate fields.

    Args:
        __field (str): The first field the validator should be called on; this is separate
            from `fields` to ensure an error is raised if you don't pass at least one.
        *fields (str): Additional field(s) the validator should be called on.
        pre (bool, optional): Whether or not this validator should be called before the standard
            validators (else after). Defaults to False.
        each_item (bool, optional): For complex objects (sets, lists etc.) whether to validate
            individual elements rather than the whole object. Defaults to False.
        always (bool, optional): Whether this method and other validators should be called even if
            the value is missing. Defaults to False.
        check_fields (bool | None, optional): Whether to check that the fields actually exist on the model.
            Defaults to None.
        allow_reuse (bool, optional): Whether to track and raise an error if another validator refers to
            the decorated function. Defaults to False.

    Returns:
        Callable: A decorator that can be used to decorate a
            function to be used as a validator.
    Tr   z`@validator` should be used with fields and keyword arguments, not bare. E.g. usage should be `@validator('<field_name>', ...)`zvalidator-no-fieldscodec                 s  s    | ]}t |tV  qd S r   )
isinstancerA   ).0fieldr   r   r   	<genexpr>y   s    zvalidator.<locals>.<genexpr>z`@validator` fields should be passed as separate string args. E.g. usage should be `@validator('<field_name_1>', '<field_name_2>', ...)`zvalidator-invalid-fieldszPydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more detailsr   
stacklevelbeforeafterfr   r   (_decorators.PydanticDescriptorProxy[Any]c                   sJ   t | rtdddt | } tj}t j d}t j| ||dS )Nz2`@validator` cannot be applied to instance methodszvalidator-instance-methodrF   )rB   moder<   r=   r>   shim)r   is_instance_method_from_sigr   %ensure_classmethod_based_on_signaturer   Zmake_generic_v1_field_validatorZValidatorDecoratorInfoPydanticDescriptorProxy)rP   wrapZvalidator_wrapper_infor=   r>   r<   rB   rR   r   r   dec   s   

zvalidator.<locals>.decN)rP   r   r   rQ   )r   _ALLOW_REUSE_WARNING_MESSAGEDeprecationWarningtuplerH   r   r   all)r@   r;   r<   r=   r>   r?   rB   rZ   r   rY   r   	validatorR   s*   
r_   .)r?   skip_on_failureLiteral[True]FCallable[[_V1RootValidatorFunctionType], _V1RootValidatorFunctionType]c                 C  r   r   r   )r`   r?   r   r   r   root_validator      rc   c                 C  r   r   r   )r;   r?   r   r   r   rc      rd   Literal[False]c                 C  r   r   r   r;   r`   r?   r   r   r   rc      s   	rf   r   c                   s|   t dtdd |rt | S |du rt tt | du rdnd | du r-|dur-tdd	d
ttj| dd fdd}|S )a  Decorate methods on a model indicating that they should be used to validate (and perhaps
    modify) data either before or after standard model parsing/validation is performed.

    Args:
        pre (bool, optional): Whether this validator should be called before the standard
            validators (else after). Defaults to False.
        skip_on_failure (bool, optional): Whether to stop validation and return as soon as a
            failure is encountered. Defaults to False.
        allow_reuse (bool, optional): Whether to track and raise an error if another validator
            refers to the decorated function. Defaults to False.

    Returns:
        Any: A decorator that can be used to decorate a function to be used as a root_validator.
    zPydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more detailsr   rL   TrN   rO   FzIf you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.zroot-validator-pre-skiprF   )r;   rP   HCallable[..., Any] | classmethod[Any, Any, Any] | staticmethod[Any, Any]r   r   c                   s8   t | r	tdt | }t j d}t j||dS )Nz7`@root_validator` cannot be applied to instance methods)rR   rS   )r   rU   	TypeErrorrV   ZRootValidatorDecoratorInforW   )rP   resZdec_inforR   rX   r   r   rZ      s
   

zroot_validator.<locals>.decN)rP   rg   r   r   )r   r\   rc   r[   r   r   r   Zmake_v1_generic_root_validator)r;   r`   r?   Z__argsrZ   r   rj   r   rc      s$   

)r@   rA   rB   rA   r;   rC   r<   rC   r=   rC   r>   rD   r?   rC   r   rE   )r`   ra   r?   rC   r   rb   )r;   ra   r?   rC   r   rb   )r;   re   r`   ra   r?   rC   r   rb   )r;   rC   r`   rC   r?   rC   r   r   )3__doc__
__future__r   Z_annotations	functoolsr   r   typesr   typingr   r   r   r	   r
   r   warningsr   Ztyping_extensionsr   r   r   	_internalr   r   errorsr   r   r[   r   r'   r,   r/   r2   r4   ZV1ValidatorWithValuesZV1ValidatorWithValuesKwOnlyZV1ValidatorWithKwargsZV1ValidatorWithValuesAndKwargsZV1ValidatorZV1RootValidatorFunctionZV1RootValidatorclassmethodstaticmethodr8   __annotations__r9   r:   r\   r_   rc   r   r   r   r   <module>   s~     ,	L

