Only ensure a valid result if the rule matches

@luisrovirosa I liked your proposal to ensure valid results only if the rule is matched.