Skip to content

Commit fdd865b

Browse files
committed
Allow type or coerce to specify coercion type
1 parent d0d7872 commit fdd865b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/grape/validations.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ def optional(*attrs)
9595
def validates(attrs, validations)
9696
doc_attrs = { :required => validations.keys.include?(:presence) }
9797

98+
# special case (type = coerce)
99+
if validations[:type]
100+
validations[:coerce] = validations.delete(:type)
101+
end
102+
98103
if coerce_type = validations[:coerce]
99104
doc_attrs[:type] = coerce_type.to_s
100105
end

0 commit comments

Comments
 (0)