Page 1 of 1

Validation Not Working

PostPosted: Fri Apr 06, 2018 4:21 pm
by Colorado4Wheeler
I'm totally befuddled with this one. I've tested this thirty ways to Sunday and it's returning False with an errorsDict and yet the action happily accepts the values and saves. Am I on crack and just not seeing something super obvious? Heck, I've even returned without checking anything and that didn't work either. I've tested and it's definitely making it into the condition to fail.

Code: Select all
   ###
   def closedActionConfigUi(self, valuesDict, userCancelled, typeId, actionId):
      """
      Validate action form.
      """
      
      errorsDict = indigo.Dict()
      
      if re.match('^[\w-]+$', valuesDict["name"]) is None:
         errorsDict["showAlertText"] = "Variable names must contain only alphanumeric letters or underscores."
         errorsDict["name"] = "Invalid character(s)"
         return (False, valuesDict, errorsDict)
      
      return (True, valuesDict, errorsDict)

Re: Validation Not Working

PostPosted: Fri Apr 06, 2018 4:52 pm
by FlyingDiver
You don't validate in closedActionConfigUi(), you validate in validateActionConfigUi(). All you can do in closed is save the changes if the user didn't cancel.

http://wiki.indigodomo.com/doku.php?id= ... in_guide&s[]=validateactionconfigui#validation_methods

Re: Validation Not Working

PostPosted: Fri Apr 06, 2018 5:10 pm
by Colorado4Wheeler
DOH! You know, I knew that but it just didn't register that I put the wrong method name down. Thank you!