pglet-python
pglet-python copied to clipboard
Validation Framework
- Inspired by ASP.NET validation.
- Works primarily with
Textboxcontrol. - Can recurively call
validate()on any control. -
.is_validproperty stores the last validation result. - Textbox implements
.validate()and.is_validdefined onControllevel. - ...or user provides
on_validatehandler 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))