Class: Apipie::Validator::NumberValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#error, #expected_type, find, inherited, #initialize, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
383
384
385
386
387
|
# File 'lib/apipie/validator.rb', line 383
def self.build(param_description, argument, options, block)
if argument == :number
self.new(param_description)
end
end
|
.validate(value) ⇒ Object
393
394
395
|
# File 'lib/apipie/validator.rb', line 393
def self.validate(value)
value.to_s =~ /\A(0|[1-9]\d*)\Z$/
end
|
Instance Method Details
#description ⇒ Object
389
390
391
|
# File 'lib/apipie/validator.rb', line 389
def description
"Must be a number."
end
|
#validate(value) ⇒ Object
379
380
381
|
# File 'lib/apipie/validator.rb', line 379
def validate(value)
self.class.validate(value)
end
|