Website.set_data_validation#
- Website.set_data_validation(func)[source]#
Validate data received from JavaScript before using it.
ToUI receives data from JavaScript in the form of JSON object. To validate this data before allowing ToUI to use it, input a function that checks the data. This function should have one argument data and should either return
TrueorFalse. If the function returnsFalse, the data will not be used by ToUI.Currently, the JSON object contains the following keys:
- {func: …,
args: …, url: …, html: …}
func contains the name of the Python function that should be called, args are the arguments of this function, url is the URL of the HTML page that sent the data, ‘html’ if the HTML document itself as a string. However, note that the structure of the JSON object might change in future versions of ToUI.
- Parameters:
func (Callable) – A function that validates data received from JavaScript. It should have one argument data and should either return
TrueorFalse.
See also