
    dfx&              
         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
r G d de      Z G d de      Z G d de      Z G d de      Z  G d de      Z! G d de      Z"eeeee e!ejF                  ejH                  ejJ                  ejL                  f	   Z'ee"ejP                  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jP                  e"e,      Z/neZ0dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d Z1ed!d"	 	 	 	 	 d)d#       Z2ed!d"	 	 	 	 	 d*d$       Z2ed!d"	 	 	 	 	 	 	 d+d%       Z2dddd&	 	 	 	 	 	 	 d,d'Z2y)-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Zy)_OnlyValueValidatorClsMethodc                     y N )self!_OnlyValueValidatorClsMethod__cls#_OnlyValueValidatorClsMethod__values      ]/home/api-vastappli/venv/lib/python3.12/site-packages/pydantic/deprecated/class_validators.py__call__z%_OnlyValueValidatorClsMethod.__call__           N)r   r   r   r   returnr   __name__
__module____qualname__r   r   r!   r   r   r          	r!   r   c                      e Zd ZddZy)_V1ValidatorWithValuesClsMethodc                     y r   r   )r   $_V1ValidatorWithValuesClsMethod__cls&_V1ValidatorWithValuesClsMethod__valuevaluess       r   r   z(_V1ValidatorWithValuesClsMethod.__call__   r    r!   N)r+   r   r,   r   r-   dict[str, Any]r"   r   r#   r   r!   r   r)   r)      r'   r!   r)   c                      e Zd ZddZy)%_V1ValidatorWithValuesKwOnlyClsMethodc                    y r   r   )r   *_V1ValidatorWithValuesKwOnlyClsMethod__cls,_V1ValidatorWithValuesKwOnlyClsMethod__valuer-   s       r   r   z._V1ValidatorWithValuesKwOnlyClsMethod.__call__   r    r!   N)r2   r   r3   r   r-   r.   r"   r   r#   r   r!   r   r0   r0      r'   r!   r0   c                      e Zd ZddZy)_V1ValidatorWithKwargsClsMethodc                     y r   r   )r   $_V1ValidatorWithKwargsClsMethod__clskwargss      r   r   z(_V1ValidatorWithKwargsClsMethod.__call__"   r    r!   N)r7   r   r8   r   r"   r   r#   r   r!   r   r5   r5   !   r'   r!   r5   c                      e Zd ZddZy)(_V1ValidatorWithValuesAndKwargsClsMethodc                     y r   r   )r   -_V1ValidatorWithValuesAndKwargsClsMethod__clsr-   r8   s       r   r   z1_V1ValidatorWithValuesAndKwargsClsMethod.__call__&   r    r!   N)r<   r   r-   r.   r8   r   r"   r   r#   r   r!   r   r:   r:   %   r'   r!   r:   c                       e Zd Z	 	 	 	 	 	 ddZy)_V1RootValidatorClsMethodc                     y r   r   )r   _V1RootValidatorClsMethod__cls!_V1RootValidatorClsMethod__valuess      r   r   z"_V1RootValidatorClsMethod.__call__*   s     r!   N)r@   r   rA   "_decorators_v1.RootValidatorValuesr"   rB   r#   r   r!   r   r>   r>   )   s    		(J	/	r!   r>   r   _PartialClsOrStaticMethod_V1ValidatorType_V1RootValidatorFunctionTypeFN)pre	each_itemalwayscheck_fieldsallow_reusec               $   |du rt        t        t               t        | g      t	        d   t
              rt        dd      t        d D              st        dd      t        d	t        d
       |du rdnddf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              3  <   K   | ]  }t        |t                y wr   )
isinstancestr).0fields     r   	<genexpr>zvalidator.<locals>.<genexpr>y   s     <EE3'<s   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afterc                    t        j                  |       rt        dd      t        j                  |       } t        j
                  }t        j                        }t        j                  | ||      S )Nz2`@validator` cannot be applied to instance methodszvalidator-instance-methodrL   )fieldsmoderG   rH   rI   shim)r   is_instance_method_from_sigr   %ensure_classmethod_based_on_signaturer   make_generic_v1_field_validatorValidatorDecoratorInfoPydanticDescriptorProxy)fwrapvalidator_wrapper_inforH   rI   rG   rY   rZ   s      r   deczvalidator.<locals>.dec   sz    2215#DKf  ==a@==!,!C!C%"
 2216LSWXXr!   )rb   r   r"   z(_decorators.PydanticDescriptorProxy[Any])r   _ALLOW_REUSE_WARNING_MESSAGEDeprecationWarningtuplerO   r   r   all)	__fieldrF   rG   rH   rI   rJ   rY   re   rZ   s	     ``` ` @r   	validatorrk   R   s    < d)+=>G%f%&F&)\*E&
 	

 <V<<Y+
 	
 		4 	 47$;xGDY Y" Jr!   .)rJ   c                     y r   r   )skip_on_failurerJ   s     r   root_validatorrn           r!   c                     y r   r   )rF   rJ   s     r   rn   rn      ro   r!   c                     y r   r   rF   rm   rJ   s      r   rn   rn      s     r!   rr   c                    t        dt        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	
      t        t        j                  |       df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   rT   TrV   rW   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-skiprL   )rF   c                    t        j                  |       rt        d      t        j                  |       }t        j                        }t        j
                  ||      S )Nz7`@root_validator` cannot be applied to instance methods)rZ   r[   )r   r]   	TypeErrorr^   RootValidatorDecoratorInfora   )rb   resdec_inforZ   rc   s      r   re   zroot_validator.<locals>.dec   sR    2215UVV??B99tD223tLLr!   )rb   zHCallable[..., Any] | classmethod[Any, Any, Any] | staticmethod[Any, Any]r"   r   )r   rg   rn   rf   r   r   r   make_v1_generic_root_validator)rF   rm   rJ   __argsre   rZ   rc   s        @@r   rn   rn      s    ( 		4 	 ~((d)+=>36$;xGD
e|t3i*
 	
 >@@cJDM Jr!   )rj   rP   rY   rP   rF   boolrG   r{   rH   r{   rI   zbool | NonerJ   r{   r"   z.Callable[[_V1ValidatorType], _V1ValidatorType])rm   Literal[True]rJ   r{   r"   FCallable[[_V1RootValidatorFunctionType], _V1RootValidatorFunctionType])rF   r|   rJ   r{   r"   r}   )rF   zLiteral[False]rm   r|   rJ   r{   r"   r}   )rF   r{   rm   r{   rJ   r{   r"   r   )3__doc__
__future__r   _annotations	functoolsr   r   typesr   typingr   r   r	   r
   r   r   warningsr   typing_extensionsr   r   r   	_internalr   r   errorsr   r   rf   r   r)   r0   r5   r:   r>   V1ValidatorWithValuesV1ValidatorWithValuesKwOnlyV1ValidatorWithKwargsV1ValidatorWithValuesAndKwargsV1ValidatorV1RootValidatorFunctionV1RootValidatorclassmethodstaticmethodrC   __annotations__rD   rE   rg   rk   rn   r   r!   r   <module>r      s   I 2 ,  I I  : : 3 & 0r  x (  ( 8 H  $'-'0,,22,,55	7
K !..	0O
 ,1S#s]1K\Z]_bZbMcersvew1w+xyx
 1;@YZ#*&..!!	$  3  $III 
I 	I
 I I I 4IX 
  #	
  M 
 
  
	
  M 
 
  
	
 #  M 
 !	4	4 4 	4
 	4r!   