dry-rb / dry-rb/dry-validation
Getting proc instead of string message
- Dominant language
- Ruby
- Stars
- 1.4k
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the bug
I am getting a callable proc in the following code.
## To Reproduce
```ruby
require 'dry-validation'
class TestContract < Dry::Validation::Contract
params do
required(:last_name).filled(:string)
optional(:birthday).maybe(:date)
end
rule(:birthday) do
key.failure('wrong date')
end
rule(:last_name) do
result.errors.to_h
end
end
validator = TestContract.new
puts validator.call(last_name: 'Last', birthday: '5.01.0202').errors.to_h
# {:birthday=>[#]}
```
## Expected behavior
`# {:birthday=>["wrong date"]}`
## My environment
- Affects my production application: **NO**
- Ruby version: 3.3.0
- OS: macOS 13.6.7
# Workaround
Make a copy of errors:
`result.errors.dup.to_h`
Contributor guide
Assessment
This issue has not been assessed yet.