Class: AFCSalesforce::Tools::Validation::Rule::Numeric
- Inherits:
-
Object
- Object
- AFCSalesforce::Tools::Validation::Rule::Numeric
- Defined in:
- lib/afc_salesforce/tools/validation/rule/numeric.rb
Overview
rule for numeric values
Instance Method Summary collapse
- #error(value) ⇒ Object
-
#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(value) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/afc_salesforce/tools/validation/rule/numeric.rb', line 12 def error(value) results = {} results[:expected] = true results[:got] = valid_value?(value) results end |
#error_key ⇒ Object
The error key for this rule
20 21 22 |
# File 'lib/afc_salesforce/tools/validation/rule/numeric.rb', line 20 def error_key :numeric end |
#params ⇒ Object
this rule has no params
25 26 27 |
# File 'lib/afc_salesforce/tools/validation/rule/numeric.rb', line 25 def params {} end |
#valid_value?(value) ⇒ Boolean
Determines if value is numeric. It can only contain whole numbers
8 9 10 |
# File 'lib/afc_salesforce/tools/validation/rule/numeric.rb', line 8 def valid_value?(value) !!/^[0-9]+$/.match(value.to_s) end |