Hi Ian,
Thanks for the reprex, we don't have validation in the python package yet, so what I'd recommend is using reactive ui components and a ui.markdown
or ui.HTML
error message. This was a popular pattern in R land prior to validate
from shiny import App, reactive, render, ui
app_ui = ui.page_fluid(
ui.input_text("x", "Type a number"),
ui.output_ui("txt1")
)
def server(input, output, session):
@output
@render.text()
def x_times_2():
val = int(input.x()) * 2
print(f"Running x_times_2(). Result is {val}.")
return val
@output
@render.text
def txt1():
if input.x().isnumeric():
return ui.output_text_verbatim("x_times_2")
else:
return ui.markdown("**Please enter a number**")
app = App(app_ui, server)