Better consistency for key? method

I’m writing a validation that tests the presence of two optional keys

rule :foo, :bar do
  unless values.key?(:foo) ^ values.key?(:bar)
    key.failure("must have one of: foo, bar")
  end
end

(Seldom do I get to write an XOR!)

It was surprising to me that I couldn’t write key?(:bar) instead, since Evaluator#key? merely forwards to Values#key?. Doesn’t seem like this omission was intentional.

I have a working patch that implements this. Are you interested in a PR?

1 Like

This makes sense, feel free to open a PR :slightly_smiling_face: