Closed kwando closed 5 years ago
I could "fix" this by patching Dry::Core::Undefined with the []
method returning self.
def undefined.[](_)
self
end
This is probably not how this should be fixed though..
Serializing back to ast is not 100% implemented in dry-logic. This is planned for 1.0.0. I'm gonna close this one since it's a dry-logic issue (I'll report it there instead).
and 3 seconds later I realized it is a dry-logic repo c(ˊᗜˋ*c)
Yep, I figured it should be fixed in here somewhere :)
I'm reverse engineering the AST since I want to convert our in-house schema spec to a dry-validation schema.
...and over 2 years later, this now works with dry-schema + latest dry-logic:
key?(:awesome) AND key[awesome](filled? AND str?)#<Dry::Logic::Operations::And rules=[#<Dry::Logic::Rule::Predicate predicate=#<Method: Dry::Logic::Predicates.key?> options={:args=>[:awesome]}>, #<Dry::Logic::Operatio
ns::Key rules=[#<Dry::Logic::Operations::And rules=[#<Dry::Logic::Rule::Predicate predicate=#<Method: Dry::Logic::Predicates.filled?> options={:args=>[]}>, #<Dry::Logic
::Rule::Predicate predicate=#<Method: Dry::Logic::Predicates.str?> options={:args=>[]}>] options={}>] options={:name=>:awesome, :evaluator=>#<Dry::Logic::Evaluator::Key
path=[:awesome]>, :path=>:awesome}>] options={}>
[:and, [[:predicate, [:key?, [[:name, :awesome], [:input, Undefined]]]], [:key, [:awesome, [:and, [[:predicate, [:filled?, [[:input, Undefined]]]], [:predicate, [:str?,
[[:input, Undefined]]]]]]]]]]