+
    7*i_|  c                  s  a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHtHtHtHtHtHtHtHt ^ RIHtHt ^ RIHtHt ^RIHtHtHt ^R	I H!t! ^R
I"H#t# ^RI$H%t% ^RIH&t&H't' ]PP                  RT8  d   ^ RIH)t) M^ RIH)t) ]PT                  t+]PX                  ! RURR/]PZ                  B  ! R R4      4       t.]PX                  ! RURR/]PZ                  B  ! R R4      4       t/]PX                  ! RURR/]PZ                  B  ! R R4      4       t0]PX                  ! RURR/]PZ                  B  ! R R4      4       t1]'       d    ! R R])4      t2 ! R R])4      t3 ! R R])4      t4 ! R R])4      t5]]3]Pl                  ]2]Pn                  3,          t8]]5]Pr                  ]4]Pt                  3,          t;]]<]]]3,          ]=]]3,          ]	],          3,          t>R ]?R!&   ]! R"]]8]>3,          R#7      t@]! R$]];]>3,          R#7      tA]RV,          tBR ]?R&&   ]R'R(R)R(/R* R+ ll4       tC]R'R(R)R(/R, R- ll4       tC]R.R(R'R(/R/ R0 ll4       tCR.R%R'RR)]/R1 R2 lltC]! R34      tD]! R4RR57      tE ! R6 R7]P                  ])]E,          4      tG ! R8 R9])]D,          4      tH ! R: R;])]D,          4      tI ! R< R=])4      tJ ! R> R?])4      tK ! R@ RA])4      tL ! RB RC])4      tM]]D.]D3,          tN ]]D]P                  ],          .]D3,          tP ]]I]D,          ]H]D,          3,          tQ]]L]M]J]K3,          tR]]P]D,          ]N]D,          3,          tS]RD RE l4       tT]RF RG l4       tT]RH RI l4       tTRJ RK ltT]! RL4      tU]'       d   ]]UR(3,          tVM)]PX                  ! RU/ ]PZ                  B  ! RM RN4      4       tV]'       d   ]]UR(3,          tWM)]PX                  ! RU/ ]PZ                  B  ! RO RP4      4       tW]! RQ4      tX ! RR RS4      tYR# )WzBThis module contains related classes and functions for validation.)annotationsN)partialmethod)FunctionType)	TYPE_CHECKING	AnnotatedAnyCallableLiteralTypeVarUnioncastoverload)PydanticUndefinedcore_schema)Self	TypeAlias)_decorators	_generics_internal_dataclass)GetCoreSchemaHandler)PydanticUserError)version_short)ArbitraryTypeWarningPydanticDeprecatedSince212)ProtocolZfrozenTc                  sH    ] tR t^t$ RtR]R&   R R lt]R R l4       tRt	R	# )
AfterValidatora  !!! abstract "Usage Documentation"
    [field *after* validators](../concepts/validators.md#field-after-validator)

A metadata class that indicates that a validation should be applied **after** the inner validation logic.

Attributes:
    func: The validator function.

Example:
    ```python
    from typing import Annotated

    from pydantic import AfterValidator, BaseModel, ValidationError

    MyInt = Annotated[int, AfterValidator(lambda v: v + 1)]

    class Model(BaseModel):
        a: MyInt

    print(Model(a=1).a)
    #> 2

    try:
        Model(a='a')
    except ValidationError as e:
        print(e.json(indent=2))
        '''
        [
          {
            "type": "int_parsing",
            "loc": [
              "a"
            ],
            "msg": "Input should be a valid integer, unable to parse string as an integer",
            "input": "a",
            "url": "https://errors.pydantic.dev/2/v/int_parsing"
          }
        ]
        '''
    ```
Kcore_schema.NoInfoValidatorFunction | core_schema.WithInfoValidatorFunctionfuncc               $    V ^8  d   QhRRRRRR/#    source_typer   handlerr   returncore_schema.CoreSchema Zformat   "C/usr/lib/python3.14/site-packages/pydantic/functional_validators.py__annotate__AfterValidator.__annotate__K   s(     U U UFZ U_u U    c                	s>   V! V4      p\        V P                  R RR7      pV'       d<   \        \        P                  V P                  4      p\        P
                  ! WSR7      # \        \        P                  V P                  4      p\        P                  ! WSR7      # )afterfieldmodeZtypeschema)_inspect_validatorr   r
   r   WithInfoValidatorFunctionZ"with_info_after_validator_functionNoInfoValidatorFunction no_info_after_validator_function)selfr   r    r/   info_argr      &&&   r&   __get_pydantic_core_schema__Z+AfterValidator.__get_pydantic_core_schema__K   so    %%diigGL==tyyIDAA$VV;;TYYGD??TTr)   c                    V ^8  d   QhRRRR/# r   	decoratorz>_decorators.Decorator[_decorators.FieldValidatorDecoratorInfo]r!   r   r#   r$   r%   r&   r'   r(   V   s     ( ((f (ko (r)   c                	s(    V ! VP                   R 7      # )r   r;   clsr:      &&r&   _from_decoratorZAfterValidator._from_decoratorU   s    	''r)   r#   N)
__name__
__module____qualname____firstlineno____doc____annotations__r7   classmethodr?   __static_attributes__r#   r)   r&   r   r      s+    (T VUU ( (r)   r   c                  sV    ] tR t^Zt$ RtR]R&   ]tR]R&   R R lt]	R R	 l4       t
R
tR# )BeforeValidatora,  !!! abstract "Usage Documentation"
    [field *before* validators](../concepts/validators.md#field-before-validator)

A metadata class that indicates that a validation should be applied **before** the inner validation logic.

Attributes:
    func: The validator function.
    json_schema_input_type: The input type used to generate the appropriate
        JSON Schema (in validation mode). The actual input type is `Any`.

Example:
    ```python
    from typing import Annotated

    from pydantic import BaseModel, BeforeValidator

    MyInt = Annotated[int, BeforeValidator(lambda v: v + 1)]

    class Model(BaseModel):
        a: MyInt

    print(Model(a=1).a)
    #> 2

    try:
        Model(a='a')
    except TypeError as e:
        print(e)
        #> can only concatenate str (not "int") to str
    ```
r   r   r   json_schema_input_typec               r   r   r#   r$   r%   r&   r'   BeforeValidator.__annotate__   s#       FZ _u r)   c                	s   V! V4      pV P                   \        J d   R MVP                  V P                   4      p\        V P                  RRR7      pV'       d>   \        \        P                  V P                  4      p\        P                  ! VVVR7      # \        \        P                  V P                  4      p\        P                  ! WcVR7      # )Nbeforer+   r,   r/   json_schema_input_schema)rI   r   generate_schemar0   r   r
   r   r1   Z#with_info_before_validator_functionr2   Z!no_info_before_validator_functionr4   r   r    r/   input_schemar5   r      &&&    r&   r7   Z,BeforeValidator.__get_pydantic_core_schema__   s    % **.?? (()D)DE 	 &diihWM==tyyIDBB)5  ;;TYYGD@@l r)   c               r8   r9   r#   r$   r%   r&   r'   rJ           
 
(f 
ko 
r)   c                	R    V ! VP                   VP                  P                  R 7      # )r   rI   r   inforI   r<   r>   r&   r?   ZBeforeValidator._from_decorator   #    #,>>#H#H
 	
r)   r#   Nr@   rA   rB   rC   rD   rE   r   rI   r7   rF   r?   rG   r#   r)   r&   rH   rH   Z   s5    @ VU"3C3, 
 
r)   rH   c                  sV    ] tR t^t$ RtR]R&   ]tR]R&   R R lt]	R R	 l4       t
R
tR# )PlainValidatora  !!! abstract "Usage Documentation"
    [field *plain* validators](../concepts/validators.md#field-plain-validator)

A metadata class that indicates that a validation should be applied **instead** of the inner validation logic.

!!! note
    Before v2.9, `PlainValidator` wasn't always compatible with JSON Schema generation for `mode='validation'`.
    You can now use the `json_schema_input_type` argument to specify the input type of the function
    to be used in the JSON schema when `mode='validation'` (the default). See the example below for more details.

Attributes:
    func: The validator function.
    json_schema_input_type: The input type used to generate the appropriate
        JSON Schema (in validation mode). The actual input type is `Any`.

Example:
    ```python
    from typing import Annotated, Union

    from pydantic import BaseModel, PlainValidator

    def validate(v: object) -> int:
        if not isinstance(v, (int, str)):
            raise ValueError(f'Expected int or str, go {type(v)}')

        return int(v) + 1

    MyInt = Annotated[
        int,
        PlainValidator(validate, json_schema_input_type=Union[str, int]),  # (1)!
    ]

    class Model(BaseModel):
        a: MyInt

    print(Model(a='1').a)
    #> 2

    print(Model(a=1).a)
    #> 2
    ```

    1. In this example, we've specified the `json_schema_input_type` as `Union[str, int]` which indicates to the JSON schema
    generator that in validation mode, the input type for the `a` field can be either a [`str`][] or an [`int`][].
r   r   r   rI   c               r   r   r#   r$   r%   r&   r'   PlainValidator.__annotate__   s#     ' ' 'FZ '_u 'r)   c           
     	s   ^ RI Hp  V! V4      pVP                  R\        P                  ! R VVP                  V4      R7      4      pVP                  V P                  4      p\        V P                  RRR7      pV'       d>   \        \        P                  V P                  4      p\        P                  ! VVVR	7      # \        \        P                  V P                  4      p\        P                  ! VVVR	7      #   T d    Rp Li ; i)
    PydanticSchemaGenerationErrorserializationc                    V! V 4      # Nr#   Zvhr>   r&   <lambda>Z=PlainValidator.__get_pydantic_core_schema__.<locals>.<lambda>       !A$r)   )functionr/   Zreturn_schemaNplainr+   r,   )r^   rM   )pydanticr]   Zgetr   #wrap_serializer_function_ser_schemarN   rI   r0   r   r
   r1   Z"with_info_plain_validator_functionr2   Z no_info_plain_validator_function)	r4   r   r    r]   r/   r^   rP   r5   r   s	   &&&      r&   r7   Z+PlainValidator.__get_pydantic_core_schema__   s     	;	![)F #JJ??.!")"9"9+"FM ..t/J/JK%diigGL==tyyIDAA+)5  ;;TYYGD??+)5  - 	! M	!s   AC> >	D
	D
c               r8   r9   r#   r$   r%   r&   r'   rZ      rR   r)   c                	rS   rT   rU   r<   r>   r&   r?   ZPlainValidator._from_decorator   rW   r)   r#   N)r@   rA   rB   rC   rD   rE   r   rI   r7   rF   r?   rG   r#   r)   r&   rY   rY      s6    ,\ VU"%C%'R 
 
r)   rY   c                  sV    ] tR tRt$ RtR]R&   ]tR]R&   R R lt]	R	 R
 l4       t
RtR# )WrapValidatori  ab  !!! abstract "Usage Documentation"
    [field *wrap* validators](../concepts/validators.md#field-wrap-validator)

A metadata class that indicates that a validation should be applied **around** the inner validation logic.

Attributes:
    func: The validator function.
    json_schema_input_type: The input type used to generate the appropriate
        JSON Schema (in validation mode). The actual input type is `Any`.

```python
from datetime import datetime
from typing import Annotated

from pydantic import BaseModel, ValidationError, WrapValidator

def validate_timestamp(v, handler):
    if v == 'now':
        # we don't want to bother with further validation, just return the new value
        return datetime.now()
    try:
        return handler(v)
    except ValidationError:
        # validation failed, in this case we want to return a default value
        return datetime(2000, 1, 1)

MyTimestamp = Annotated[datetime, WrapValidator(validate_timestamp)]

class Model(BaseModel):
    a: MyTimestamp

print(Model(a='now').a)
#> 2032-01-02 03:04:05.000006
print(Model(a='invalid').a)
#> 2000-01-01 00:00:00
```
zScore_schema.NoInfoWrapValidatorFunction | core_schema.WithInfoWrapValidatorFunctionr   r   rI   c               r   r   r#   r$   r%   r&   r'   WrapValidator.__annotate__,  s#       FZ _u r)   c                	s   V! V4      pV P                   \        J d   R MVP                  V P                   4      p\        V P                  RRR7      pV'       d>   \        \        P                  V P                  4      p\        P                  ! VVVR7      # \        \        P                  V P                  4      p\        P                  ! VVVR7      # )Nwrapr+   r,   rL   )rI   r   rN   r0   r   r
   r   WithInfoWrapValidatorFunctionZ!with_info_wrap_validator_functionNoInfoWrapValidatorFunctionZno_info_wrap_validator_functionrO   rQ   r&   r7   Z*WrapValidator.__get_pydantic_core_schema__,  s    % **.?? (()D)DE 	 &diif7KAA499MD@@)5  ??KD>>)5 r)   c               r8   r9   r#   r$   r%   r&   r'   rj   E  rR   r)   c                	rS   rT   rU   r<   r>   r&   r?   ZWrapValidator._from_decoratorD  rW   r)   r#   NrX   r#   r)   r&   ri   ri     s5    $L ^]"3C30 
 
r)   ri   c                  "    ] tR tRtR R ltRtR# )_OnlyValueValidatorClsMethodiN  c               $    V ^8  d   QhRRRRRR/# r   r=   r   valuer!   r#   r$   r%   r&   r'   Z)_OnlyValueValidatorClsMethod.__annotate__O  s    ???C?s?r)   c               	    R # r`   r#   r4   r=   rr      """r&   __call__Z%_OnlyValueValidatorClsMethod.__call__O  s    Cr)   r#   Nr@   rA   rB   rC   rv   rG   r#   r)   r&   ro   ro   N  s    ??r)   ro   c                  rn   )_V2ValidatorClsMethodiQ  c               (    V ^8  d   QhRRRRRRRR/# r   r=   r   rr   rV   core_schema.ValidationInfo[Any]r!   r#   r$   r%   r&   r'   Z"_V2ValidatorClsMethod.__annotate__R  s    fffCf7Vf^afr)   c               	rs   r`   r#   r4   r=   rr   rV      """"r&   rv   Z_V2ValidatorClsMethod.__call__R  s    cfr)   r#   Nrw   r#   r)   r&   rx   rx   Q  s    ffr)   rx   c                  rn   ) _OnlyValueWrapValidatorClsMethodiT  c               ry   )r   r=   r   rr   r    (core_schema.ValidatorFunctionWrapHandlerr!   r#   r$   r%   r&   r'   Z-_OnlyValueWrapValidatorClsMethod.__annotate__U  s    rrrCr:brjmrr)   c               	rs   r`   r#   r4   r=   rr   r    r}   r&   rv   Z)_OnlyValueWrapValidatorClsMethod.__call__U  s    orr)   r#   Nrw   r#   r)   r&   r~   r~   T  s    rrr)   r~   c                  rn   )_V2WrapValidatorClsMethodiW  c          
     s,    V ^8  d   QhRRRRRRRRRR/# )	r   r=   r   rr   r    r   rV   r{   r!   r#   r$   r%   r&   r'   Z&_V2WrapValidatorClsMethod.__annotate__X  s<     	 		 	 >		
 2	 	r)   c               	rs   r`   r#   r4   r=   rr   r    rV      """""r&   rv   Z"_V2WrapValidatorClsMethod.__call__X  s     r)   r#   Nrw   r#   r)   r&   r   r   W  s    	 	r)   r   r   _PartialClsOrStaticMethod"_V2BeforeAfterOrPlainValidatorType)Zbound_V2WrapValidatorTyper*   FieldValidatorModescheck_fields.rI   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   r+   strfieldsr-   Literal['wrap']r   bool | NonerI   r   r!   z6Callable[[_V2WrapValidatorType], _V2WrapValidatorType]r#   r$   r%   r&   r'   r'   {  sN     A AA A 	A
 A  A <Ar)   c              rs   r`   r#   r+   r-   r   rI   r      "$$$*r&   field_validatorr   z  s     >Ar)   c               r   )r   r+   r   r   r-   zLiteral['before', 'plain']r   r   rI   r   r!   RCallable[[_V2BeforeAfterOrPlainValidatorType], _V2BeforeAfterOrPlainValidatorType]r#   r$   r%   r&   r'   r'     sO     ] ]] ] %	]
 ]  ] X]r)   c              rs   r`   r#   r   r   r&   r   r     s	     Z]r)   r-   c          
     s,    V ^8  d   QhRRRRRRRRRR	/# )
r   r+   r   r   r-   Literal['after']r   r   r!   r   r#   r$   r%   r&   r'   r'     sD     ] ]] ] 	]
 ] X]r)   c              rs   r`   r#   )r+   r-   r   r   s   "$$*r&   r   r     s	     Z]r)   c               r   )r   r+   r   r   r-   r   r   r   rI   r   r!   zCallable[[Any], Any]r#   r$   r%   r&   r'   r'     sN     l ll l 	l
 l  l lr)   c              sx  aaaa \        V \        4      '       d   \        RRR7      hSR9  d   S\        Jd   \        RS: 2RR7      hS\        J d   SR8X  d   \        oV .SO5o\
        ;QJ d    R S 4       F  '       d   K   RM	  R	M! R S 4       4      '       g   \        R
RR7      hR VVVV3R llpV# )a  !!! abstract "Usage Documentation"
    [field validators](../concepts/validators.md#field-validators)

Decorate methods on the class indicating that they should be used to validate fields.

Example usage:
```python
from typing import Any

from pydantic import (
    BaseModel,
    ValidationError,
    field_validator,
)

class Model(BaseModel):
    a: str

    @field_validator('a')
    @classmethod
    def ensure_foobar(cls, v: Any):
        if 'foobar' not in v:
            raise ValueError('"foobar" not found in a')
        return v

print(repr(Model(a='this is foobar good')))
#> Model(a='this is foobar good')

try:
    Model(a='snap')
except ValidationError as exc_info:
    print(exc_info)
    '''
    1 validation error for Model
    a
      Value error, "foobar" not found in a [type=value_error, input_value='snap', input_type=str]
    '''
```

For more in depth examples, see [Field Validators](../concepts/validators.md#field-validators).

Args:
    field: The first field the `field_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: Additional field(s) the `field_validator` should be called on.
    mode: Specifies whether to validate the fields before or after validation.
    check_fields: Whether to check that the fields actually exist on the model.
    json_schema_input_type: The input type of the function. This is only used to generate
        the appropriate JSON Schema (in validation mode) and can only specified
        when `mode` is either `'before'`, `'plain'` or `'wrap'`.

Returns:
    A decorator that can be used to decorate a function to be used as a field_validator.

Raises:
    PydanticUserError:
        - If `@field_validator` is used bare (with no fields).
        - If the args passed to `@field_validator` as fields are not strings.
        - If `@field_validator` applied to instance methods.
z`@field_validator` should be used with fields and keyword arguments, not bare. E.g. usage should be `@validator('<field_name>', ...)`zvalidator-no-fieldsZcoderf   z;`json_schema_input_type` can't be used when mode is set to zvalidator-input-typec              3  sB   "   T F  p\        V\        4      x  K  	  R # 5ir`   )
isinstancer   )Z.0r+   s   & r&   Z	<genexpr>Z"field_validator.<locals>.<genexpr>  s     :6%z%%%6s   FTz`@field_validator` fields should be passed as separate string args. E.g. usage should be `@validator('<field_name_1>', '<field_name_2>', ...)`zvalidator-invalid-fieldsc               r8   )r   fzHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]r!   (_decorators.PydanticDescriptorProxy[Any]r#   r$   r%   r&   r'   Z%field_validator.<locals>.__annotate__  s      @ @S@	1@r)   c                s   < \         P                  ! V 4      '       d   \        R RR7      h\         P                  ! V 4      p \         P                  ! SSSSR7      p\         P
                  ! W4      # )z8`@field_validator` cannot be applied to instance methodszvalidator-instance-methodr   )r   r-   r   rI   )r   Zis_instance_method_from_sigr   %ensure_classmethod_based_on_signatureZFieldValidatorDecoratorInfoPydanticDescriptorProxy)r   dec_infor   r   rI   r-   s   & r&   decZfield_validator.<locals>.dec  sh     22155#JQl 
 ==a@::<Xn
 221??r)   )rK   rf   rk   )r   r   r   r   r   Zall)r+   r-   r   rI   r   r   s   "dddj r&   r   r     s    H %&&E&
 	
 ..3IQb3bI$R'
 	

 !22tw!$^V^F3:6:333:6:::Y+
 	
@ @  Jr)   
_ModelType_ModelTypeCo)Z	covariantc                  s*    ] tR tRtRtRR R lltRtR# )ModelWrapValidatorHandleri  z]`@model_validator` decorated function handler argument type. This is used when `mode='wrap'`.Nc               r   )r   rr   r   outer_locationzstr | int | Noner!   r   r#   r$   r%   r&   r'   Z&ModelWrapValidatorHandler.__annotate__  s(       )
 
r)   c               	rs   r`   r#   )r4   rr   r   ru   r&   rv   Z"ModelWrapValidatorHandler.__call__  s     	r)   r#   r`   r@   rA   rB   rC   rD   rv   rG   r#   r)   r&   r   r     s    g r)   r   c                  &    ] tR tRtRtR R ltRtR# )ModelWrapValidatorWithoutInfoi  zA `@model_validator` decorated function signature.
This is used when `mode='wrap'` and the function does not have info argument.
c               s(    V ^8  d   QhRRRRRRRR/# )	r   r=   type[_ModelType]rr   r   r    %ModelWrapValidatorHandler[_ModelType]r!   r   r#   r$   r%   r&   r'   Z*ModelWrapValidatorWithoutInfo.__annotate__  s2     	 		 	 7	 
	r)   c               	rs   r`   r#   r   r}   r&   rv   Z&ModelWrapValidatorWithoutInfo.__call__  s     r)   r#   Nr   r#   r)   r&   r   r     s    	 	r)   r   c                  r   )ModelWrapValidatori*  zSA `@model_validator` decorated function signature. This is used when `mode='wrap'`.c          
     s,    V ^8  d   QhRRRRRRRRR	R
/# )r   r=   r   rr   r   r    r   rV   zcore_schema.ValidationInfor!   r   r#   r$   r%   r&   r'   ZModelWrapValidator.__annotate__-  s<     
 

 
 7
 )
 

r)   c               	rs   r`   r#   r   r   r&   rv   ZModelWrapValidator.__call__-  s     r)   r#   Nr   r#   r)   r&   r   r   *  s    ]
 
r)   r   c                  r   )#FreeModelBeforeValidatorWithoutInfoi:  A `@model_validator` decorated function signature.
This is used when `mode='before'` and the function does not have info argument.
c                    V ^8  d   QhRRRR/# )r   rr   r   r!   r#   r$   r%   r&   r'   Z0FreeModelBeforeValidatorWithoutInfo.__annotate__?  s       
  
r)   c               	rs   r`   r#   )r4   rr   s   ""r&   rv   Z,FreeModelBeforeValidatorWithoutInfo.__call__?  s     r)   r#   Nr   r#   r)   r&   r   r   :  s     r)   r   c                  r   )ModelBeforeValidatorWithoutInfoiI  r   c               rp   rq   r#   r$   r%   r&   r'   Z,ModelBeforeValidatorWithoutInfo.__annotate__N  s(        
r)   c               	rs   r`   r#   rt   ru   r&   rv   Z(ModelBeforeValidatorWithoutInfo.__call__N       r)   r#   Nr   r#   r)   r&   r   r   I  s     r)   r   c                  r   )FreeModelBeforeValidatoriY  UA `@model_validator` decorated function signature. This is used when `mode='before'`.c               s$    V ^8  d   QhRRRRRR/# )r   rr   r   rV   r{   r!   r#   r$   r%   r&   r'   Z%FreeModelBeforeValidator.__annotate__\  s*      
  . 
r)   c               	rs   r`   r#   )r4   rr   rV   ru   r&   rv   Z!FreeModelBeforeValidator.__call__\  r   r)   r#   Nr   r#   r)   r&   r   r   Y  s    _ r)   r   c                  r   )ModelBeforeValidatorig  r   c               ry   rz   r#   r$   r%   r&   r'   Z!ModelBeforeValidator.__annotate__j  s2     	 		 	 .	 
	r)   c               	rs   r`   r#   r|   r}   r&   rv   ZModelBeforeValidator.__call__j  s     r)   r#   Nr   r#   r)   r&   r   r   g  s    _	 	r)   r   c               r8   )r   r-   r   r!   z|Callable[[_AnyModelWrapValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]]r#   r$   r%   r&   r'   r'     s      
r)   c                rs   r`   r#   r-      $r&   model_validatorr          r)   c               r8   )r   r-   zLiteral['before']r!   zrCallable[[_AnyModelBeforeValidator], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]]r#   r$   r%   r&   r'   r'     s      
r)   c                rs   r`   r#   r   r   r&   r   r     r   r)   c               r8   )r   r-   r   r!   z}Callable[[_AnyModelAfterValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]]r#   r$   r%   r&   r'   r'     s      
r)   c                rs   r`   r#   r   r   r&   r   r     r   r)   c               r8   )r   r-   z"Literal['wrap', 'before', 'after']r!   r   r#   r$   r%   r&   r'   r'     s"     A A
,A 	Ar)   c                s   a  R V 3R llpV# )a  !!! abstract "Usage Documentation"
    [Model Validators](../concepts/validators.md#model-validators)

Decorate model methods for validation purposes.

Example usage:
```python
from typing_extensions import Self

from pydantic import BaseModel, ValidationError, model_validator

class Square(BaseModel):
    width: float
    height: float

    @model_validator(mode='after')
    def verify_square(self) -> Self:
        if self.width != self.height:
            raise ValueError('width and height do not match')
        return self

s = Square(width=1, height=1)
print(repr(s))
#> Square(width=1.0, height=1.0)

try:
    Square(width=1, height=2)
except ValidationError as e:
    print(e)
    '''
    1 validation error for Square
      Value error, width and height do not match [type=value_error, input_value={'width': 1, 'height': 2}, input_type=dict]
    '''
```

For more in depth examples, see [Model Validators](../concepts/validators.md#model-validators).

Args:
    mode: A required string literal that specifies the validation mode.
        It can be one of the following: 'wrap', 'before', or 'after'.

Returns:
    A decorator that can be used to decorate a function to be used as a model validator.
c               r8   )r   r   r   r!   r   r#   r$   r%   r&   r'   Z%model_validator.<locals>.__annotate__  s     @ @s @? @r)   c                s  < \         P                  ! V 4      p SR 8X  d@   \        V \        4      '       d*   \        P
                  ! \        R\        4        R2^R7       \         P                  ! SR7      p\         P                  ! W4      # )r*   zUsing `@model_validator` with mode='after' on a classmethod is deprecated. Instead, use an instance method. See the documentation at https://docs.pydantic.dev/z,/concepts/validators/#model-after-validator.)ZcategoryZmessageZ
stacklevelr   )
r   r   r   rF   warningsZwarnr   r   ZModelValidatorDecoratorInfor   )r   r   r-   s   & r&   r   Zmodel_validator.<locals>.dec  sx    ==a@7?z![99MM3JJW/IZ  [GH  ::E221??r)   r#   )r-   r   s   d r&   r   r     s    b@ @  Jr)   AnyTypec                  s^    ] tR tRtRt]R R l4       t]R R l4       t]P                  t	Rt
R# )	
InstanceOfi  u  Generic type for annotating a type that is an instance of a given class.

Example:
    ```python
    from pydantic import BaseModel, InstanceOf

    class Foo:
        ...

    class Bar(BaseModel):
        foo: InstanceOf[Foo]

    Bar(foo=Foo())
    try:
        Bar(foo=42)
    except ValidationError as e:
        print(e)
        """
        [
        │   {
        │   │   'type': 'is_instance_of',
        │   │   'loc': ('foo',),
        │   │   'msg': 'Input should be an instance of Foo',
        │   │   'input': 42,
        │   │   'ctx': {'class': 'Foo'},
        │   │   'url': 'https://errors.pydantic.dev/0.38.0/v/is_instance_of'
        │   }
        ]
        """
    ```
c               r   )r   itemr   r!   r#   r$   r%   r&   r'   InstanceOf.__annotate__  s     	* 	* 	*W 	*r)   c                	s(    \         W! 4       3,          # r`   )r   r=   r   r>   r&   __class_getitem__ZInstanceOf.__class_getitem__  s    T35[))r)   c               r   r   sourcer   r    r   r!   r"   r#   r$   r%   r&   r'   r     s(     	x 	xc 	xDX 	x]s 	xr)   c                	s   ^ RI Hp \        P                  ! \        P
                  ! V4      ;'       g    T4      p V! V4      p\        P                  ! R VR7      VR&   \        P                  ! WER7      #   T d    Tu # i ; i)r[   r\   c                r_   r`   r#   ra   r>   r&   rc   Z9InstanceOf.__get_pydantic_core_schema__.<locals>.<lambda>#  rd   r)   re   r/   r^   )Zpython_schemaZjson_schema)rg   r]   r   Zis_instance_schemar   Z
get_originrh   Zjson_or_python_schema)r=   r   r    r]   Zinstance_of_schemaoriginal_schemar6   r&   r7   Z'InstanceOf.__get_pydantic_core_schema__  s    > "-!?!?	@T@TU[@\@f@f`f!gx")&/ 7B6e6e.7"?3 #88GYww 1 *))*s   A7 7	BBr#   N)r@   rA   rB   rC   rD   rF   r   r7   object__hash__rG   r#   r)   r&   r   r     s=    	@ 
	* 
	* 
	x 
	x& ??r)   r   c                  sT    ] tR tRtRtR R lt]R R l4       t]P                  t	Rt
R# )	SkipValidationi.  at  If this is applied as an annotation (e.g., via `x: Annotated[int, SkipValidation]`), validation will be
    skipped. You can also use `SkipValidation[int]` as a shorthand for `Annotated[int, SkipValidation]`.

This can be useful if you want to use a type annotation for documentation/IDE/type-checking purposes,
and know that it is safe to skip validation for one or more of the fields.

Because this converts the validation schema to `any_schema`, subsequent annotation-applied transformations
may not have the expected effects. Therefore, when used, this annotation should generally be the final
annotation applied to a type.
c               r   )r   r   r   r!   r#   r$   r%   r&   r'   SkipValidation.__annotate__;  s     	5 	5 	5 	5r)   c                	s0    \         V\        4       3,          # r`   )r   r   r   r>   r&   r   Z SkipValidation.__class_getitem__;  s    T>#3344r)   c               r   r   r#   r$   r%   r&   r'   r   ?  s#     
	 
	c 
	DX 
	]s 
	r)   c                	s,  a \         P                  ! 4       ;_uu_ 4        \         P                  ! R \        4       V! V4      oRRR4       RV3R l./p\        P
                  ! V\        P                  ! R SR7      R7      #   + '       g   i     LH; i)ZignoreNZ pydantic_js_annotation_functionsc                s   < V! S4      # r`   r#   )Z_crb   r   s   &&r&   rc   =SkipValidation.__get_pydantic_core_schema__.<locals>.<lambda>C  s
    1_K]r)   c                r_   r`   r#   ra   r>   r&   rc   r   G  rd   r)   r   )metadatar^   )r   Zcatch_warningsZsimplefilterr   r   Z
any_schemarh   )r=   r   r    r   r   s   &&& @r&   r7   Z+SkipValidation.__get_pydantic_core_schema__>  ss    ((**%%h0DE")&/ + ;=]<^_H))!)MM. 	 +*s   $BB	r#   N)r@   rA   rB   rC   rD   r   rF   r7   r   r   rG   r#   r)   r&   r   r   .  s+    			5 

	 

	 ??r)   r   
_FromTypeTc                  s2    ] tR tRtRtR R ltR R ltRtR# )	
ValidateAsiQ  a-  A helper class to validate a custom type from a type that is natively supported by Pydantic.

Args:
    from_type: The type natively supported by Pydantic to use to perform validation.
    instantiation_hook: A callable taking the validated type as an argument, and returning
        the populated custom type.

Example:
    ```python {lint="skip"}
    from typing import Annotated

    from pydantic import BaseModel, TypeAdapter, ValidateAs

    class MyCls:
        def __init__(self, a: int) -> None:
            self.a = a

        def __repr__(self) -> str:
            return f"MyCls(a={self.a})"

    class Model(BaseModel):
        a: int


    ta = TypeAdapter(
        Annotated[MyCls, ValidateAs(Model, lambda v: MyCls(a=v.a))]
    )

    print(ta.validate_python({'a': 1}))
    #> MyCls(a=1)
    ```
c               r   )r   instantiation_hookzCallable[[_FromTypeT], Any]	from_typeztype[_FromTypeT]r!   ZNoner#   r$   r%   r&   r'   ValidateAs.__annotate__t  s$     5 5Kf 5"2 5ko 5r)   c               	s    Wn         W n        R # r`   r   r   )r4   r   r   s   ""&r&   __init__ZValidateAs.__init__t  s    ""4r)   c               r   r   r#   r$   r%   r&   r'   r   x  s#     
 
3 
AU 
Zp 
r)   c                	sj    V! V P                   4      p\        P                  ! V P                  VR 7      # )r.   )r   r   r3   r   )r4   r   r    r/   s   &&& r&   r7   Z'ValidateAs.__get_pydantic_core_schema__x  s/    (;;##
 	
r)   r   N)r@   rA   rB   rC   rD   r   r7   rG   r#   r)   r&   r   r   Q  s    D5
 
r)   r   )i   i   r#   )rK   r*   rk   rf   )Z__conditional_annotations__rD   Z
__future__r    Z_annotationsZdataclassesZsysr   Z	functoolsr   Ztypesr   Ztypingr   r   r   r   r   r   r	   r
   r   Zpydantic_corer   r   Ztyping_extensionsr   r   Z	_internalr   r   r   Zannotated_handlersr   Zerrorsr   Zversionr   r   r   Zversion_infor   Zinspect_validatorr0   Z	dataclassZ
slots_truer   rH   rY   ri   ro   rx   r~   r   r1   r2   Z_V2Validatorrl   rm   Z_V2WrapValidatorrF   Zstaticmethodr   rE   r   r   r   r   r   r   ZValidatorFunctionWrapHandlerr   r   r   r   r   r   r   ZModelAfterValidatorWithoutInfoZValidationInfoZModelAfterValidatorZ_AnyModelWrapValidatorZ_AnyModelBeforeValidatorZ_AnyModelAfterValidatorr   r   r   r   r   r   )r   s   @r&   <module>r      s   H 2  
  #  c c c 8 - B B 4 % " Fg* 22  EdE&9&D&DE9( 9( F9(x EdE&9&D&DE?
 ?
 F?
D EdE&9&D&DE`
 `
 F`
F EdE&9&D&DEG
 G
 FG
T @x @g gs8 sH  --$++	-L !11(//	1 ,1S#s]1K\Z]_bZbMcersvew1w+xyx)0,L";;<*& ##9GWYrGrAst!()K!L Y L 
A
 !$A #&A 
A 
]
 !$] #&] 
] 
] !	]
 !$] 
]l !(	l
 !%l #4l^ \"
~6	 H H(S_J` 	HZ$8 "*-  ( h  x 8  "*:,
*B!C  
K,F,Fs,KLjXY  Z1*=?\]g?hhi  24WYxx    3J ?A_`jAk kl  
 
 
 
 
 
AH )
 7C<(J <0;;<9# 9# =9#x w|,N <0;;<# # =#> \"
,
 ,
r)   