Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building contract failed when or-ing types #712

Closed
sdalu opened this issue Aug 24, 2022 · 2 comments
Closed

Building contract failed when or-ing types #712

sdalu opened this issue Aug 24, 2022 · 2 comments

Comments

@sdalu
Copy link

sdalu commented Aug 24, 2022

The following code result in key not found: "int?" (Dry::Container::KeyError)

module Types
  include Dry::Types()
end
class B < Dry::Validation::Contract
  json do
    optional(:id).filled(Types::Integer | Types::String)
  end
end

dry-validation: 1.8.1
dry-schema: 1.10.2
dry-types: 1.5.1
ruby: 3.1.2

@solnic
Copy link
Member

solnic commented Aug 25, 2022

Please provide a reproduction script, the snippet you provided works for me.

@solnic solnic closed this as completed Aug 25, 2022
@solnic
Copy link
Member

solnic commented Aug 25, 2022

oh and btw, I would do it like that anyway:

optional(:id) { int? | (str? & filled?) }

This makes more sense, because it's supposed to be either an integer or a string that's not empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants