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

Key map differs when maybe(:hash) is used #266

Closed
flash-gordon opened this issue Mar 8, 2020 · 0 comments · Fixed by #269
Closed

Key map differs when maybe(:hash) is used #266

flash-gordon opened this issue Mar 8, 2020 · 0 comments · Fixed by #269
Assignees
Labels
Milestone

Comments

@flash-gordon
Copy link
Member

Describe the bug

When contracted syntax maybe(:hash) is used it affects the output of .key_map which in order breaks valid path checks for rules in dry-validation.

To Reproduce

dry-schema> schema { required(:foo).maybe(:hash) { optional(:bar) } }.key_map
=> #<Dry::Schema::KeyMap[:foo]>
dry-schema> schema { required(:foo).maybe { hash { optional(:bar) } } }.key_map
=> #<Dry::Schema::KeyMap[{:foo=>[:bar]}]>

Expected behavior

Outputs to be the same.

Your environment

  • Affects my production application: IN A WAY
  • Ruby version: 2.7.0
  • OS: n/a
@solnic solnic added this to the 1.5.0 milestone Mar 9, 2020
@solnic solnic self-assigned this Mar 9, 2020
solnic added a commit that referenced this issue Mar 10, 2020
Fix building up key maps for maybe(:hash)

[changelog]

fixed: "Key map is properly inferred for maybe-hashes (issue #266 fixed via #269) (@solnic)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants