pglet-python icon indicating copy to clipboard operation
pglet-python copied to clipboard

Validation Framework

Open FeodorFitsner opened this issue 3 years ago • 0 comments

  • Inspired by ASP.NET validation.
  • Works primarily with Textbox control.
  • Can recurively call validate() on any control.
  • .is_valid property stores the last validation result.
  • Textbox implements .validate() and .is_valid defined on Control level.
  • ...or user provides on_validate handler which returns a message if the value is invalid, for example:
first_name = Textbox(label="First name", on_validate=lambda v: "Please enter your first name" if v == "" else None)

or providing a Validator class:

first_name = Textbox(label="First name", validator=RequiredFieldValidator("Please enter your first name", focus_on_error=True))

FeodorFitsner avatar Feb 23 '22 04:02 FeodorFitsner