Class: Apipie::Validator::DecimalValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #error, find, #format_description_value, #ignore_allow_blank?, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #param_name, #params_ordered, raise_if_missing_params, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
438
439
440
441
442
|
# File 'lib/apipie/validator.rb', line 438
def self.build(param_description, argument, options, block)
if argument == :decimal
self.new(param_description)
end
end
|
.validate(value) ⇒ Object
452
453
454
|
# File 'lib/apipie/validator.rb', line 452
def self.validate(value)
value.to_s =~ /\A^[-+]?[0-9]+([,.][0-9]+)?\Z$/
end
|
Instance Method Details
#description ⇒ Object
444
445
446
|
# File 'lib/apipie/validator.rb', line 444
def description
"Must be a decimal number."
end
|
#expected_type ⇒ Object
448
449
450
|
# File 'lib/apipie/validator.rb', line 448
def expected_type
'numeric'
end
|
#validate(value) ⇒ Object
434
435
436
|
# File 'lib/apipie/validator.rb', line 434
def validate(value)
self.class.validate(value)
end
|