Related to my question the other day - Using importlib to run any function on the gateway?
Now with forms, I like to run a validation on the client side so that the window doesn’t close and the user has a chance to fix their mistakes. And if that validation runs fine, then it sends a message to the gateway to run the actual create script.
However, I know it’s not enough to just validate client side, and I should run it on the gateway end as well to be safe in case someone is able to start running my modules in a way not intended.
But the validation function is the same no matter the scope what changes is the what it does at the end.
Is there a way to do something like the following:
def validate(...):
if someCondition:
raise ValueError("Something wrong")
.....
scope = system.someScriptHere()
if scope == "client":
system.util.sendMessage(...)
elif scope == "gateway":
return 1