Class: ApipieDSL::Validator::NumberValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #docs, find, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #sub_params, #to_s, #valid?
Class Method Details
.build(param_description, argument, _options, _block) ⇒ Object
382
383
384
385
386
|
# File 'lib/apipie_dsl/validator.rb', line 382
def self.build(param_description, argument, _options, _block)
return if argument != :number
new(param_description)
end
|
Instance Method Details
#description ⇒ Object
392
393
394
|
# File 'lib/apipie_dsl/validator.rb', line 392
def description
'Must be a number'
end
|
#expected_type ⇒ Object
396
397
398
|
# File 'lib/apipie_dsl/validator.rb', line 396
def expected_type
'numeric'
end
|
#validate(value) ⇒ Object
388
389
390
|
# File 'lib/apipie_dsl/validator.rb', line 388
def validate(value)
value.to_s =~ /\A(0|[1-9]\d*)\Z$/
end
|