Input Validation for Shiny apps
Project description
shiny_validate
Overview
This is a python implementation of shinyvalidate, which provides input validation for Shiny for Python applications.
Installation
Install from Pypi with:
pip install shiny_validate
Or, you can install the latest development version from GitHub using the remotes
package.
pip install git+https://github.com/rstudio/shinyvalidate.git
Basic usage
To add validation to your Shiny app, you need to:
-
Create an InputValidator object:
iv <- InputValidator
-
Add one or more validation rules to the InputValidator:
iv.add_rule("title", check.required())
-
Turn the validator on:
iv$enable()
That's all you need to do to get validation messages to show up.
from shiny import App, ui, render, req
from shiny_validate import InputValidator, check
app_ui = ui.page_fluid(
ui.input_text("name", "Name"),
ui.input_text("email", "Email"),
ui.output_text("greeting"),
)
def server(input, output, session):
iv = InputValidator()
iv.add_rule("name", check.required())
iv.add_rule("email", check.required())
iv.add_rule("email", check.email())
iv.enable()
@render.text
def greeting():
req(iv.is_valid())
return f"Nice to meet you, {input.name()} <{input.email()}>!"
app = App(app_ui, server)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shiny_validate-0.1.tar.gz
(35.0 kB
view hashes)
Built Distribution
Close
Hashes for shiny_validate-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23189ee9c895159c1e0b48d28c04ecc586b90843bde3bd199e1ba20b23e816a0 |
|
MD5 | 079e7b77fb536164f7947645f037feb2 |
|
BLAKE2b-256 | eb0a5dc4739c7b0b9036fbc390281eac03c6ca2fc2598da0499773fa2abd10ce |