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:
pip install git+https://github.com/posit-dev/py-shiny-validate.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)
You can also use the .is_valid() method to ensure that the inputs are valid before rendering an output:
@render.plot
def plot():
req(iv.is_valid())
# Build and return a plot if the inputs are valid
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shiny_validate-0.1.3.tar.gz.
File metadata
- Download URL: shiny_validate-0.1.3.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db3f530e0af99c792fb8fe1b3feb760658ce88ea5a35fbb88b8a23c2403291e8
|
|
| MD5 |
70d63cbbc5b2728a7df97eb983d70a92
|
|
| BLAKE2b-256 |
3a5f499b52ae5f5ccde146a2718feea2fc11ef3411ecaed58f5cdec1c6cd49f4
|
Provenance
The following attestation bundles were made for shiny_validate-0.1.3.tar.gz:
Publisher:
publish.yml on posit-dev/py-shiny-validate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shiny_validate-0.1.3.tar.gz -
Subject digest:
db3f530e0af99c792fb8fe1b3feb760658ce88ea5a35fbb88b8a23c2403291e8 - Sigstore transparency entry: 183456260
- Sigstore integration time:
-
Permalink:
posit-dev/py-shiny-validate@c1acbe6b63c4211e257096b93b7fc8e096ae14ce -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/posit-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1acbe6b63c4211e257096b93b7fc8e096ae14ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file shiny_validate-0.1.3-py3-none-any.whl.
File metadata
- Download URL: shiny_validate-0.1.3-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c66842f9b5e9deab8ba87eb6437cb14bbe470c603550d7055acfd3ec1f5d0f70
|
|
| MD5 |
c2dffe1b89606e61717d5a930899c438
|
|
| BLAKE2b-256 |
590de022d169e127413cbdb9cfe0b1a8e45a77ba78adc6ea5a3a4c820cdc0b64
|
Provenance
The following attestation bundles were made for shiny_validate-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on posit-dev/py-shiny-validate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shiny_validate-0.1.3-py3-none-any.whl -
Subject digest:
c66842f9b5e9deab8ba87eb6437cb14bbe470c603550d7055acfd3ec1f5d0f70 - Sigstore transparency entry: 183456264
- Sigstore integration time:
-
Permalink:
posit-dev/py-shiny-validate@c1acbe6b63c4211e257096b93b7fc8e096ae14ce -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/posit-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1acbe6b63c4211e257096b93b7fc8e096ae14ce -
Trigger Event:
push
-
Statement type: