@@ -110,6 +110,7 @@ def input_dialog(
110110 cancel_text : str = "Cancel" ,
111111 completer : Completer | None = None ,
112112 validator : Validator | None = None ,
113+ validate_while_typing : FilterOrBool = False ,
113114 password : FilterOrBool = False ,
114115 style : BaseStyle | None = None ,
115116 default : str = "" ,
@@ -124,7 +125,9 @@ def accept(buf: Buffer) -> bool:
124125 return True # Keep text.
125126
126127 def ok_handler () -> None :
127- get_app ().exit (result = textfield .text )
128+ textfield .buffer .validate () # validate one final time before exiting
129+ if textfield .buffer .validation_error is None :
130+ get_app ().exit (result = textfield .text )
128131
129132 ok_button = Button (text = ok_text , handler = ok_handler )
130133 cancel_button = Button (text = cancel_text , handler = _return_none )
@@ -135,6 +138,7 @@ def ok_handler() -> None:
135138 password = password ,
136139 completer = completer ,
137140 validator = validator ,
141+ validate_while_typing = validate_while_typing ,
138142 accept_handler = accept ,
139143 )
140144
@@ -144,7 +148,7 @@ def ok_handler() -> None:
144148 [
145149 Label (text = text , dont_extend_height = True ),
146150 textfield ,
147- ValidationToolbar (),
151+ ValidationToolbar (buffer = textfield . buffer ),
148152 ],
149153 padding = D (preferred = 1 , max = 1 ),
150154 ),
0 commit comments