Disable coercion?

11 views
Skip to first unread message

Tim Jones

unread,
Oct 18, 2023, 2:21:22 PM10/18/23
to Grape Framework Discussion
Is it possible to disable coercion for all types/requests?  Currently if I setup the following params structure

params do
  requires :user, type: Hash do
    requires :name, type: String
  end
end

and send this JSON input, Grape will happily cast the integer 1 to a string.  I'd like it to return a 400.

{ "user": { name: 1 } }

Thanks!

Daniel D.

unread,
Oct 19, 2023, 3:12:52 PM10/19/23
to ruby-...@googlegroups.com
I am surprised this coerces automatically actually. I think this is either a feature request or a bug, feel free to open it. 

--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-grape/5b0566a1-ea51-41a5-9dc9-8efb44346711n%40googlegroups.com.


--

dB. | Moscow - Geneva - Seattle - New York
code.dblock.org - t:@dblockdotorg - ig:@artdblockdotorggithub/dblock

Reply all
Reply to author
Forward
0 new messages