o
    1Éli‹  ã                   @   s6   d Z ddlmZ dd„ Zddd„Zdd	„ Zd
d„ ZdS )z
Common validation functions
é    )Ú
basestringc                 C   s   t | tƒstd|| f ƒ‚dS )z<Require that value is a string

    :raises: TypeError

    z+%s must be a str or unicode str, but got %rN)Ú
isinstancer   Ú	TypeError)ÚvalueÚ
value_name© r   ú_/var/www/html/tatsat2dev/dashboard-backend/venv/lib/python3.10/site-packages/pika/validators.pyÚrequire_string   s   
þÿr	   Úcallbackc                 C   s   t | ƒstd|| f ƒ‚dS )zORequire that callback is callable and is not None

    :raises: TypeError

    z(callback %s must be callable, but got %rN©Úcallabler   )r
   Úcallback_namer   r   r   Úrequire_callback   s   þÿr   c                 C   s    | du rdS t | ƒrdS tdƒ‚)z~Verify callback is callable if not None

    :returns: boolean indicating nowait
    :rtype: bool
    :raises: TypeError

    NTFz0completion callback must be callable if not Noner   ©r
   r   r   r   Úrpc_completion_callback"   s
   r   c                 C   s$   t |ƒdk rd | |¡}t|ƒ‚dS )zuVerify that value is zero or greater. If not, 'name'
    will be used in error message

    :raises: ValueError

    r   z{} must be >= 0, but got {}N)ÚintÚformatÚ
ValueError)Únamer   Úerrmsgr   r   r   Úzero_or_greater6   s   þr   Nr   )Ú__doc__Úpika.compatr   r	   r   r   r   r   r   r   r   Ú<module>   s    
