Custom validators.



Validate kernel input using a kernel code completeness call.


Abstract base class for an input validator.


ValidationError([cursor_position, message])

Error raised by Validator.validate().

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

Bases: 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) 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')
  • 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.