Class: Validation::Rule::Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/validation/rule/numeric.rb

Overview

rule for numeric values

Instance Method Summary collapse

Instance Method Details

#error_keyObject

The error key for this rule



11
12
13
# File 'lib/validation/rule/numeric.rb', line 11

def error_key
  :numeric
end

#paramsObject

this rule has no params



16
17
18
# File 'lib/validation/rule/numeric.rb', line 16

def params
  {}
end

#valid_value?(value) ⇒ Boolean

Determines if value is numeric. It can only contain whole numbers

Returns:

  • (Boolean)


6
7
8
# File 'lib/validation/rule/numeric.rb', line 6

def valid_value?(value)
 !!/^[0-9]+$/.match(value.to_s)
end