Skip to content

Commit

Permalink
validates limit_by node
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenquin committed Oct 10, 2024
1 parent 277b3a4 commit ce2710d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/arel/nodes/limit_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ class LimitBy < Arel::Nodes::Unary
attr_reader :column

def initialize(limit, column)
@column = column
raise ArgumentError, 'Limit should be an integer' unless limit.is_a?(Integer)
raise ArgumentError, 'Limit should be a positive integer' unless limit >= 0
raise ArgumentError, 'Column should be a Symbol or String' unless column.is_a?(String) || column.is_a?(Symbol)

super(limit)
end

private

def sanitize(value)
value
end
end
end
end

0 comments on commit ce2710d

Please sign in to comment.