def validate_constraints(template, state, outputs, param_name_to_attribute, verbose):
    """
    Validate that the current state comply with the constraints as defined in the template
    """
    for constraint in template['constraints']:
        if constraint['type'] == 'NEQ':
            # Fail if both value are the same
            first_value = state['vals'].get(constraint['params'][0])
            second_value = state['vals'].get(constraint['params'][1])

            if first_value is not None and second_value is not None and first_value == second_value:
                if verbose:
                    print('skipping due to NEQ constraint')
                    print(constraint)
                    print(state['vals'])
                return False

        elif constraint['type'] == 'NULL':
            # Fail if the parameter have a value
            if state['vals'].get(constraint['params'][0]) is not None:
                if verbose:
                    print('skipping due to NULL constraint')
                    print(constraint)
                    print(state['vals'])
                return False

        elif constraint['type'] == 'NOT_NULL':
            # Fail if the parameter have an empty value
            if state['vals'].get(constraint['params'][0]) is not None:
                if verbose:
                    print('skipping due to NOT NULL constraint')
                    print(constraint)
                    print(state['vals'])
                return False

        elif constraint['type'] == 'OUT_NEQ':
            # Fail if both values refer to the same sound
            first_index = state['input_map'].get(constraint['params'][0], None)
            second_index = state['input_map'].get(constraint['params'][1], None)
            if first_index is not None and second_index is not None and outputs[first_index] == outputs[second_index]:
                if verbose:
                    print('skipping due to OUT_NEQ constraint')
                return False

        else:
            assert False, 'Unrecognized constraint type "%s"' % constraint['type']

    return True