'Performs some basic validations on decisions. The real SWF service
seems to break early and *not* process any decision if there\'s a
validation problem, such as a malformed decision for instance. I didn\'t
find an explicit documentation for that though, so criticisms welcome.'

def validate_decisions(self, decisions):

    problems = []
    for dcs in decisions[:(-1)]:
        close_decision_types = [u'CompleteWorkflowExecution', u'FailWorkflowExecution', u'CancelWorkflowExecution']
        if (dcs[u'decisionType'] in close_decision_types):
            raise SWFValidationException(u'Close    must    be    last    decision    in    list')
    decision_number = 0
    for dcs in decisions:
        decision_number += 1
        attrs_to_check = [d for d in dcs.keys() if d.endswith(u'DecisionAttributes')]
        if (dcs[u'decisionType'] in self.KNOWN_DECISION_TYPES):
            decision_type = dcs[u'decisionType']
            decision_attr = u'{0}DecisionAttributes'.format(decapitalize(decision_type))
            attrs_to_check.append(decision_attr)
        for attr in attrs_to_check:
            problems += self._check_decision_attributes(attr, dcs.get(attr, {}), decision_number)
        if (dcs[u'decisionType'] not in self.KNOWN_DECISION_TYPES):
            problems.append({u'type': u'bad_decision_type', u'value': dcs[u'decisionType'], u'where': u'decisions.{0}.member.decisionType'.format(decision_number), u'possible_values': u',    '.join(self.KNOWN_DECISION_TYPES)})
    if any(problems):
        raise SWFDecisionValidationException(problems)
