
                             d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 dZ
 G d d	e      Z G d
 d e	ee            Z G d de      Zy)zV
Input validation for a `Buffer`.
(Validators will be called before accepting input.)
    )unicode_literals   )to_simple_filter)ABCMetaabstractmethod)with_metaclass)ConditionalValidatorValidationError	Validatorc                   *     e Zd ZdZd fd	Zd Z xZS )r
   z
    Error raised by :meth:`.Validator.validate`.

    :param cursor_position: The cursor position where the error occured.
    :param message: Text.
    c                 H    t         t        |   |       || _        || _        y N)superr
   __init__cursor_positionmessage)selfr   r   	__class__s      ,lib/third_party/prompt_toolkit/validation.pyr   zValidationError.__init__   s!    ot-g6.    c                 h    | j                   j                  d| j                  d| j                  dS )Nz(cursor_position=z
, message=))r   __name__r   r   )r   s    r   __repr__zValidationError.__repr__   s)    NN##T%9%94<<I 	Ir   )r    )r   
__module____qualname____doc__r   r   __classcell__)r   s   @r   r
   r
      s    
Ir   r
   c                        e Zd ZdZed        Zy)r   z5
    Abstract base class for an input validator.
    c                      y)z
        Validate the input.
        If invalid, this should raise a :class:`.ValidationError`.

        :param document: :class:`~prompt_toolkit.document.Document` instance.
        N r   documents     r   validatezValidator.validate'   s     	r   N)r   r   r   r   r   r%   r"   r   r   r   r   #   s      r   r   c                       e Zd ZdZd Zd Zy)r	   zq
    Validator that can be switched on/off according to
    a filter. (This wraps around another validator.)
    c                 V    t        |t              sJ || _        t        |      | _        y r   )
isinstancer   	validatorr   filter)r   r)   r*   s      r   r   zConditionalValidator.__init__7   s%    )Y///"&v.r   c                 \    | j                         r| j                  j                  |       y y r   )r*   r)   r%   r#   s     r   r%   zConditionalValidator.validate=   s"    ;;=NN##H- r   N)r   r   r   r   r   r%   r"   r   r   r	   r	   2   s    /.r   r	   N)r   
__future__r   filtersr   abcr   r   sixr   __all__	Exceptionr
   objectr   r	   r"   r   r   <module>r3      sL    ( % ' Ii I"w/ .9 .r   