Skip to main content

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:

  1. Create an InputValidator object: iv <- InputValidator

  2. Add one or more validation rules to the InputValidator: iv.add_rule("title", check.required())

  3. 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


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.1.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

shiny_validate-0.1.1-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file shiny_validate-0.1.1.tar.gz.

File metadata

  • Download URL: shiny_validate-0.1.1.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for shiny_validate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3187f65c8f8dd768361cede476cef6deffed69f674b0d7a0a128a95cf9c0772c
MD5 44ae15d9eb9992b979ecf14e35fe135a
BLAKE2b-256 e5a9248f3b769157390f3b981507cc4a1e9022bed911f99209a2de7cb695cef6

See more details on using hashes here.

File details

Details for the file shiny_validate-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for shiny_validate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec9ddb00c6911fab43607ec437feefd868d28ace04c98e65011a0cb3603edfcc
MD5 93843eb7914a3c1180bf05a945f9397c
BLAKE2b-256 2bbcee172a4310722ae35d1c36b8cffdc8fd266cf8814a1b9e956976f59488be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page