class_docstr: Abstract base class for an input validator.
  
  A validator is typically created in one of the following two ways:
  
  - Either by overriding this class and implementing the `validate` method.
  - Or by passing a callable to `Validator.from_callable`.
  
  If the validation takes some time and needs to happen in a background
  thread, this can be wrapped in a :class:`.ThreadedValidator`.
class_docstr_tok: ["Abstract","base","class","for","an","input","validator",".","A","validator","is","typically","created","in","one","of","the","following","two","ways",":","-","Either","by","overriding","this","class","and","implementing","the","`","validate","`","method",".","-","Or","by","passing","a","callable","to","`","Validator.from_callable","`",".","If","the","validation","takes","some","time","and","needs","to","happen","in","a","background","thread",",","this","can","be","wrapped","in","a",":","class",":","`",".ThreadedValidator","`","."]
docstr: Create a validator from a simple validate callable. E.g.:
  
  .. code:: python
  
      def is_valid(text):
          return text in ['hello', 'world']
      Validator.from_callable(is_valid, error_message='Invalid input')
  
  :param validate_func: Callable that takes the input string, and returns
      `True` if the input is valid input.
  :param error_message: Message to be displayed if the input is invalid.
  :param move_cursor_to_end: Move the cursor to the end of the input, if
      the input is invalid.
docstr_tok: ["Create","a","validator","from","a","simple","validate","callable",".","E.g",".",":","..","code",":",":","python","def","is_valid","(","text",")",":","return","text","in","[","'hello","'",",","'world","'","]","Validator.from_callable","(","is_valid",",","error_message='Invalid","input","'",")",":","param","validate_func",":","Callable","that","takes","the","input","string",",","and","returns","`","True","`","if","the","input","is","valid","input",".",":","param","error_message",":","Message","to","be","displayed","if","the","input","is","invalid",".",":","param","move_cursor_to_end",":","Move","the","cursor","to","the","end","of","the","input",",","if","the","input","is","invalid","."]
code: def from_callable(
      cls,
      validate_func: Callable[[str], bool],
      error_message: str = "Invalid input",
      move_cursor_to_end: bool = False,
  ) -> Validator:
      """
      Create a validator from a simple validate callable. E.g.:
  
      .. code:: python
  
          def is_valid(text):
              return text in ['hello', 'world']
          Validator.from_callable(is_valid, error_message='Invalid input')
  
      :param validate_func: Callable that takes the input string, and returns
          `True` if the input is valid input.
      :param error_message: Message to be displayed if the input is invalid.
      :param move_cursor_to_end: Move the cursor to the end of the input, if
          the input is invalid.
      """
      return _ValidatorFromCallable(
          validate_func, error_message, move_cursor_to_end
      )
  
imports: from __future__ import annotations
  from abc import ABCMeta, abstractmethod
  from typing import Callable
  from prompt_toolkit.eventloop import run_in_executor_with_context
  from .document import Document
  from .filters import FilterOrBool, to_filter
label_desc: Use image node_id 2 for calling the Validator obj's underlying member method code with example usage: obj.from_callable(cls, validate_func, error_message, move_cursor_to_end) and returns: _ValidatorFromCallable