You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
994 B
Lua

local tonumber = tonumber
return function(minimum, maximum)
return {
messages = {
affirmative = {
standard = "{{placeholder}} must be between {{minimum}} and {{maximum}}",
number = "{{placeholder}} must be a number to be compared to {{minimum}} and {{maximum}}"
},
negative = {
standard = "{{placeholder}} cannot be between {{minimum}} and {{maximum}}",
number = "{{placeholder}} cannot be a number to be compared to {{minimum}} and {{maximum}}"
}
},
apply = function(context)
context.minimum = minimum
context.maximum = maximum
local number = tonumber(context.input)
if not number then
context.result = false
context.template = "number"
return
end
context.result = (number >= minimum and number <= maximum)
end
}
end