o
    7D©i	  ã                   @   sˆ   d Z ddlmZ ddlmZmZ ddlmZmZ ddlm	Z	 ede
eeedƒZe	ddd	œd
edeeedf deeedf fdd„ƒZdS )zBetween.é    )Údatetime)ÚTypeVarÚUnioné   )ÚAbsMaxÚAbsMin)Ú	validatorÚPossibleValueTypesN)Úmin_valÚmax_valÚvaluer
   r   c            
   C   sx   | du rdS |du rt ƒ }|du rtƒ }z
||krtdƒ‚W n ty/ } ztdƒ|‚d}~ww ||   ko9|kS   S )a-  Validate that a number is between minimum and/or maximum value.

    This will work with any comparable type, such as floats, decimals and dates
    not just integers. This validator is originally based on [WTForms-NumberRange-Validator][1].

    [1]: https://github.com/wtforms/wtforms/blob/master/src/wtforms/validators.py#L166-L220

    Examples:
        >>> from datetime import datetime
        >>> between(5, min_val=2)
        True
        >>> between(13.2, min_val=13, max_val=14)
        True
        >>> between(500, max_val=400)
        ValidationError(func=between, args={'value': 500, 'max_val': 400})
        >>> between(
        ...     datetime(2000, 11, 11),
        ...     min_val=datetime(1999, 11, 11)
        ... )
        True

    Args:
        value:
            Value which is to be compared.
        min_val:
            The minimum required value of the number.
            If not provided, minimum value will not be checked.
        max_val:
            The maximum value of the number.
            If not provided, maximum value will not be checked.

    Returns:
        (Literal[True]): If `value` is in between the given conditions.
        (ValidationError): If `value` is not in between the given conditions.

    Raises:
        (ValueError): If `min_val` is greater than `max_val`.
        (TypeError): If there's a type mismatch during comparison.

    Note:
        - `PossibleValueTypes` = `TypeVar("PossibleValueTypes", int, float, str, datetime)`
        - If neither `min_val` nor `max_val` is provided, result will always be `True`.
    NFz*`min_val` cannot be greater than `max_val`zComparison type mismatch)r   r   Ú
ValueErrorÚ	TypeError)r   r
   r   Úerr© r   úK/var/www/Datamplify/venv/lib/python3.10/site-packages/validators/between.pyÚbetween   s   3ÿ
€ÿr   )Ú__doc__r   Útypingr   r   Ú	_extremesr   r   Úutilsr   ÚintÚfloatÚstrr	   r   r   r   r   r   Ú<module>   s     ûÿüû