- 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))
Textboxcontrol.validate()on any control..is_validproperty stores the last validation result..validate()and.is_validdefined onControllevel.on_validatehandler which returns a message if the value is invalid, for example:or providing a
Validatorclass: