code: def is_valid(condition):
          
          matched = False
  
          if len(condition) > 0:
              final_condition = re.sub('{{.*}}', '42', condition)
              ast_tokens = Condition.get_tokens(final_condition)
              ast_compressed_tokens = Condition.compress_tokens(ast_tokens)
  
              for rule in Condition.RULES:
                  if Condition.match_tokens(ast_compressed_tokens, rule['types']):
                      matched = True
                      break
          else:
              matched = True
  
          return matched
docs: Verify condition (format).
  
          >>> Condition.is_valid('{{ foo }} == 42')
          True
          >>> Condition.is_valid('"{{ foo }}" == 42')
          False
          >>> Condition.is_valid('  not "{{ foo }}" == "42"  ')
          True
          >>> Condition.is_valid('  not {{ foo }} == 42  ')
          True
          >>> Condition.is_valid('{{ foo }} in [ 42, 43, 44 ]')
          True