euporie.core.validation

Custom validators.

Classes

KernelValidator(kernel)

Validate kernel input using a kernel code completeness call.

Validator()

Abstract base class for an input validator.

Exceptions

ValidationError([cursor_position, message])

Error raised by Validator.validate().

class euporie.core.validation.KernelValidator(kernel: Kernel)

Bases: prompt_toolkit.validation.Validator

Validate kernel input using a kernel code completeness call.

classmethod from_callable(validate_func: Callable[[str], bool], error_message: str = 'Invalid input', move_cursor_to_end: bool = False) prompt_toolkit.validation.Validator

Create a validator from a simple validate callable. E.g.:

def is_valid(text):
    return text in ['hello', 'world']
Validator.from_callable(is_valid, error_message='Invalid input')
Parameters
  • validate_func – Callable that takes the input string, and returns True if the input is valid input.

  • error_message – Message to be displayed if the input is invalid.

  • move_cursor_to_end – Move the cursor to the end of the input, if the input is invalid.

validate(document: Document) None

Validate the input synchronously.

async validate_async(document: Document) None

Return a Future which is set when the validation is ready.