-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Form: format? misleading error message #131
Comments
This one's slightly more interesting than the other "the maybe macro looks to be causing problems" cases I just commented on. I have a question before I go any further though: you're testing a When I use the form = Dry::Validation.Form do
required(:foo).required(format?: /foo/)
end
result = form.call('foo' => { 'a' => '1' })
# TypeError: no implicit conversion of Hash into String
# from /Users/tim/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-logic-0.2.2/lib/dry/logic/predicates.rb:153:in `match' |
@timriley Thanks for your reply!
With Rack based apps, we can receive three kind of values: string, array or hash. Because we don't have control on incoming data (and we shall never trust it), I'm testing form hijacking here: what happens if I expect a string, but I receive a hash? That's the purpose of the test. |
This is caused by a bad behavior of dry-types, the input processor in this case fails but dry-v uses a "safe type" which rescues from type errors and...returns original input. That's why you get back original hash and I was aware of this issue, just forgot to report it. We should use a different strategy for dry-types hash schemas that we use for input processing. What we want is a hash schema type which simply tries to process values and leave them as original values even when coercion failed. This concept doesn't exist at all in dry-types yet, we gotta add it. Right now |
The text was updated successfully, but these errors were encountered: