We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
hash?
With a schema like this, with a single rule inside a single level of nesting:
schema = Dry::Validation.Schema do key(:meta) do hash? do key(:pages).required(:int?) end end end
When I call it with invalid data, the error messages are not properly nested:
schema.(meta: {pages: "123"}).messages # => {:meta=>["must be an integer"]}
FWIW, if I set the meta hash without any child keys, the error messages are properly nested:
meta
schema.(meta: {}).messages # => {:meta=>{:pages=>["is missing"]}}
This only seems to be a problem for keys inside a hash? block. If I use a nested schema instead:
schema = Dry::Validation.Schema do key(:meta).schema do key(:pages).required(:int?) end end
Then the error messages come back properly:
schema.(meta: {pages: "123"}).messages # => {:meta=>{:pages=>["must be an integer"]}}
The text was updated successfully, but these errors were encountered:
f2fefde
No branches or pull requests
With a schema like this, with a single rule inside a single level of nesting:
When I call it with invalid data, the error messages are not properly nested:
FWIW, if I set the
meta
hash without any child keys, the error messages are properly nested:This only seems to be a problem for keys inside a
hash?
block. If I use a nested schema instead:Then the error messages come back properly:
The text was updated successfully, but these errors were encountered: