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
custom types can set a message to be used in the response when invalid
Just return an instance of `Grape::Types::InvalidValue` with the message:
class Color
def self.parse(value)
return value if %w[blue red green].include?(value)
Grape::Types::InvalidValue.new('Invalid color')
end
end
Any raised exception will be treated as an invalid value as it was before.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
#### Features
4
4
5
5
* Your contribution here.
6
+
*[#2157](https://github.com/ruby-grape/grape/pull/2157): Custom types can set a message to be used in the response when invalid - [@dnesteryuk](https://github.com/dnesteryuk).
0 commit comments