Class: Apipie::Validator::NumberValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #error, find, #format_description_value, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
441
442
443
444
445
|
# File 'lib/apipie/validator.rb', line 441
def self.build(param_description, argument, options, block)
if argument == :number
self.new(param_description)
end
end
|
.validate(value) ⇒ Object
455
456
457
|
# File 'lib/apipie/validator.rb', line 455
def self.validate(value)
value.to_s =~ /\A(0|[1-9]\d*)\Z$/
end
|
Instance Method Details
#description ⇒ Object
447
448
449
|
# File 'lib/apipie/validator.rb', line 447
def description
"Must be a number."
end
|
#expected_type ⇒ Object
451
452
453
|
# File 'lib/apipie/validator.rb', line 451
def expected_type
'numeric'
end
|
#validate(value) ⇒ Object
437
438
439
|
# File 'lib/apipie/validator.rb', line 437
def validate(value)
self.class.validate(value)
end
|