Open
Description
Validation does not work with input_dialog.
how to reproduce the issue
from prompt_toolkit.validation import Validator
from prompt_toolkit.shortcuts import input_dialog
from prompt_toolkit.validation import Validator
def is_number(text):
return text.isdigit()
validator = Validator.from_callable(
is_number,
error_message='This input contains non-numeric characters')
age = input_dialog(title="Age", text="Your age:",
validator=validator).run()
print(f"Your age: {age}")
Fill the input dialog with some string (eg: abc) and press tab key to move focus on OK button. Then press enter key.
Output
Your age: abc
Output expected
Error message on focus lost
About the environment
$ python -V
Python 3.11.1
$ pip freeze
prompt-toolkit==3.0.36
wcwidth==0.2.6
Metadata
Metadata
Assignees
Labels
No labels