Class: Apipie::Validator::DecimalValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #error, #expected_type, 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
418
419
420
421
422
|
# File 'lib/apipie/validator.rb', line 418
def self.build(param_description, argument, options, block)
if argument == :decimal
self.new(param_description)
end
end
|
.validate(value) ⇒ Object
428
429
430
|
# File 'lib/apipie/validator.rb', line 428
def self.validate(value)
value.to_s =~ /\A^[-+]?[0-9]+([,.][0-9]+)?\Z$/
end
|
Instance Method Details
#description ⇒ Object
424
425
426
|
# File 'lib/apipie/validator.rb', line 424
def description
"Must be a decimal number."
end
|
#validate(value) ⇒ Object
414
415
416
|
# File 'lib/apipie/validator.rb', line 414
def validate(value)
self.class.validate(value)
end
|