class Apipie::Validator::NumberValidator

Public Class Methods

build(param_description, argument, options, block) click to toggle source
# File lib/apipie/validator.rb, line 249
def self.build(param_description, argument, options, block)
  if argument == :number
    self.new(param_description)
  end
end
validate(value) click to toggle source
# File lib/apipie/validator.rb, line 263
def self.validate(value)
  value.to_s =~ %r\A(0|[1-9]\d*)\Z$/
end

Public Instance Methods

description() click to toggle source
# File lib/apipie/validator.rb, line 259
def description
  "Has to be a number."
end
error() click to toggle source
# File lib/apipie/validator.rb, line 255
def error
  "Parameter #{param_name} expecting to be a number, got: #{@error_value}"
end
validate(value) click to toggle source
# File lib/apipie/validator.rb, line 245
def validate(value)
  self.class.validate(value)
end