euporie.core.validation
Custom validators.
Classes
|
Validate kernel input using a kernel code completeness call. |
Abstract base class for an input validator. |
Exceptions
|
Error raised by |
- 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.