o
    ãË·e(  ã                   @   s.   d dl mZmZ d dlmZ eddd„ƒZdS )é   )ÚMaxÚMin)Ú	validatorNc                 C   st   |du r|du rt dƒ‚|du rt}|du rt}z||k}W n ty+   ||k }Y nw |r2t dƒ‚|| ko9|| k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`_.

    .. _WTForms NumberRange validator:
       https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py

    Examples::

        >>> from datetime import datetime

        >>> between(5, min=2)
        True

        >>> between(13.2, min=13, max=14)
        True

        >>> between(500, max=400)
        ValidationFailure(func=between, args=...)

        >>> between(
        ...     datetime(2000, 11, 11),
        ...     min=datetime(1999, 11, 11)
        ... )
        True

    :param min:
        The minimum required value of the number. If not provided, minimum
        value will not be checked.
    :param max:
        The maximum value of the number. If not provided, maximum value
        will not be checked.

    .. versionadded:: 0.2
    Nz1At least one of `min` or `max` must be specified.z `min` cannot be more than `max`.)ÚAssertionErrorr   r   Ú	TypeError)ÚvalueÚminÚmaxÚ
min_gt_max© r   úI/var/www/ideatree/venv/lib/python3.10/site-packages/validators/between.pyÚbetween   s    )ÿÿr   )NN)Úextremesr   r   Úutilsr   r   r   r   r   r   Ú<module>   s    