Class: Katello::Apipie::Validators::NumberValidator

Inherits:
Apipie::Validator::BaseValidator
  • Object
show all
Defined in:
lib/katello/apipie/validators.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(param_description, argument, _options, _block) ⇒ Object



37
38
39
40
41
# File 'lib/katello/apipie/validators.rb', line 37

def self.build(param_description, argument, _options, _block)
  if argument == :number
    self.new(param_description)
  end
end

Instance Method Details

#descriptionObject



47
48
49
# File 'lib/katello/apipie/validators.rb', line 47

def description
  "number."
end

#errorObject



43
44
45
# File 'lib/katello/apipie/validators.rb', line 43

def error
  "Parameter #{param_name} expecting to be a number, got: #{@error_value}"
end

#validate(value) ⇒ Object



33
34
35
# File 'lib/katello/apipie/validators.rb', line 33

def validate(value)
  value.to_s =~ /^(0|[1-9]\d*)$/
end