FIX: Validation of min_posts and max_posts didn't work

This commit is contained in:
Gerhard Schlager
2018-08-16 10:36:02 +02:00
parent 8e3b685aa4
commit 937ab3f213
2 changed files with 10 additions and 4 deletions

View File

@@ -13,14 +13,14 @@ class TopicQuery
def self.validators
@validators ||= begin
zero_or_more = lambda do |x|
Integer === x && x >= 0
end
int = lambda do |x|
Integer === x || (String === x && x.match?(/^-?[0-9]+$/))
end
zero_or_more = lambda do |x|
int.call(x) && x.to_i >= 0
end
array_int_or_int = lambda do |x|
int.call(x) || (
Array === x && x.length > 0 && x.all?(&int)