Website.set_data_validation#

Website.set_data_validation(func)#

Validates data received from JavaScript before using it.

ToUI receives data from JavaScript in the form of a 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 True or False. If the function returns False, the data will not be used by ToUI.

You can check the structures of the data received from JavaScript in https://toui.readthedocs.io/en/latest/how_it_works.html#instructions-sent-and-received. Note that the structures of the JSON objects 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 True or False.