Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
indigo_2025.1_documentation:object_model_reference [2025/10/22 19:58] – [Validate Email Address] jayindigo_2025.1_documentation:object_model_reference [2025/10/22 20:09] (current) – [Boolean Functions] jay
Line 483: Line 483:
 === Boolean Functions === === Boolean Functions ===
  
-This function will accept an email address string and validate that it is constructed correctlyNote: it does not attempt to determine if the email address exists on the destination systemonly that it is constructed correctly.+There are two functions available that will help scripters and developers in converting and using strings that represent boolean values, but are not ''True'' and ''False''. 
 + 
 +The first is ''str_to_bool(valstr)''. It will convert the string passed in to a boolean value and return it. We use the following map and it's reverse to do the mapping: 
 + 
 +<code> 
 +BOOL_MAP_TRUE: dict[str, str] = { 
 +    "y": "n", 
 +    "yes": "no", 
 +    "t": "f", 
 +    "true": "false", 
 +    "on": "off", 
 +    "1": "0", 
 +    "open": "closed", 
 +    "locked": "unlocked", 
 +
 +</code> 
 + 
 +^ Command Syntax Examples ^ 
 +|<code>indigo.utils.str_to_bool("closed")</code>
 + 
 +^  Parameters  ^^^^ 
 +^  Parameter  ^  Required  ^  Type  ^  Description 
 +|''val'' Yes  |  string  |a string that represents a boolean value as mapped above| 
 + 
 +Returns ''True'' for true values, ''False'' for values that are false, and will raise an ''indigo.utils.ValueError'' if the input can't be successfully converted. 
 + 
 +The second is ''reverse_bool_str_value(val: str)''. It will return the string that represents the opposite boolean value using the map above.
  
 ^ Command Syntax Examples ^ ^ Command Syntax Examples ^
-|<code>indigo.utils.validate_email_address("[email protected]")</code>+|<code>indigo.utils.reverse_bool_str_value("closed")</code>|
-|<code>indigo.utils.validate_email_address("invalid address will return false")</code>|+
  
 ^  Parameters  ^^^^ ^  Parameters  ^^^^
 ^  Parameter  ^  Required  ^  Type  ^  Description  ^ ^  Parameter  ^  Required  ^  Type  ^  Description  ^
-|''address'' Yes  |  string  |a string that represents an email address|+|''val'' Yes  |  string  |a string that represents a boolean value for which we want the opposite string value|
  
-Returns ''True'' for an email that is constructed correctly, ''False'' otherwise.+This example returns ''open'' since that's the opposite of ''closed''. It will raise an ''indigo.utils.ValueError'' if the input can't be successfully found.
  
  • /www/perceptive/wiki/data/attic/indigo_2025.1_documentation/object_model_reference.1761163089.txt.gz
  • Last modified: 2025/10/22 19:58
  • by jay