Validation Not Working

Posted on
Fri Apr 06, 2018 4:21 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Validation Not Working

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)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Fri Apr 06, 2018 4:52 pm
FlyingDiver offline
User avatar
Posts: 7213
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Validation Not Working

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

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 06, 2018 5:10 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Validation Not Working

DOH! You know, I knew that but it just didn't register that I put the wrong method name down. Thank you!

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests