You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I pass a string to this param I would expect to get back a page is invalid error, as the type is Integer. If you omit the values condition, this works.
But in my example, it seems the values condition is processed before the type is checked, resulting in #<NoMethodError: undefined method `positive?' for \"testing\":String> exception.
Does the values condition have priority by design? Should any values conditions be robust enough to handle various types?
Thanks :)
The text was updated successfully, but these errors were encountered:
There's clearly some order, in this case you're always getting the "raw" value, not a coerced one, so I think the "right" way here would be to rewrite -> (v) { v.is_a?(Numeric) && v.positive? }, no?
I'll close this, but feel free to reopen if you feel strongly otherwise and describe what you think should happen here.
Apologies if this is a dupe or if it turns out i'm doing something wrong :)
Reporting an odd behavior with types and values conditions.
Example: optional param that has to be a positive integer
If I pass a string to this param I would expect to get back a
page is invalid
error, as the type is Integer. If you omit thevalues
condition, this works.But in my example, it seems the
values
condition is processed before the type is checked, resulting in#<NoMethodError: undefined method `positive?' for \"testing\":String>
exception.Does the values condition have priority by design? Should any values conditions be robust enough to handle various types?
Thanks :)
The text was updated successfully, but these errors were encountered: