dry-rb / dry-logic

Predicate logic with rule composition
https://dry-rb.org/gems/dry-logic/
MIT License
179 stars 66 forks source link

`dry-types 1.5.1` is broken with `dry-logic ~>1.3` #100

Closed ojab closed 1 year ago

ojab commented 1 year ago

Describe the bug

I guess it could be expected (i. e. dry-types should be updated to >~ 1.6 to make it work), but for the user it's unexpected.

To Reproduce

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'dry-types', '1.5.1'
  gem 'dry-logic', '~> 1.3'
end

module Types
  include Dry.Types()

  Email = String.constrained(format: /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i)
  Age = Integer.constrained(gt: 18)
end
$ ruby /tmp/d.rb 
…/gems/dry-types-1.5.1/lib/dry/types/constraints.rb:20:in `block in Rule': undefined method `build' for Dry::Logic::Rule::Predicate:Class (NoMethodError)

          Logic::Rule::Predicate.build(
                                ^^^^^^

Expected behavior

It works!

My environment

flash-gordon commented 1 year ago

I don't think there's much to be done beyond updating dry-types. Since dry-types depends on dry-logic, one can consider it a bug in dry-types.