Class: ApipieDSL::Validator::NumberValidator

Inherits:
BaseValidator show all
Defined in:
lib/apipie_dsl/validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#param_description

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseValidator

#==, #docs, find, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #sub_params, #to_s, #valid?

Constructor Details

This class inherits a constructor from ApipieDSL::Validator::BaseValidator

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

#descriptionObject



392
393
394
# File 'lib/apipie_dsl/validator.rb', line 392

def description
  'Must be a number'
end

#expected_typeObject



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