Class: Validation::Rule::Numeric
- Inherits:
-
Object
- Object
- Validation::Rule::Numeric
- Defined in:
- lib/validation/rule/numeric.rb
Overview
rule for numeric values
Instance Method Summary collapse
-
#error_key ⇒ Object
The error key for this rule.
-
#params ⇒ Object
this rule has no params.
-
#valid_value?(value) ⇒ Boolean
Determines if value is numeric.
Instance Method Details
#error_key ⇒ Object
The error key for this rule
11 12 13 |
# File 'lib/validation/rule/numeric.rb', line 11 def error_key :numeric end |
#params ⇒ Object
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
6 7 8 |
# File 'lib/validation/rule/numeric.rb', line 6 def valid_value?(value) !!/^[0-9]+$/.match(value.to_s) end |