Class: WhyValidationsSuckIn96::ValidatesNumericality
- Inherits:
-
WhyValidationsSuckIn96::Validation
- Object
- WhyValidationsSuckIn96::Validation
- WhyValidationsSuckIn96::ValidatesNumericality
- Includes:
- WhyValidationsSuckIn96::AttributeBasedValidation, WhyValidationsSuckIn96::SkippableValidation
- Defined in:
- lib/whyvalidationssuckin96/macros/validates_numericality.rb
Overview
Checks to see if a given attribute is a valid numerical value. Allows a certain degree of latitude in determining what is a valid numerical value, like allowing commas and spaces in the value for example.
Constant Summary
- DefaultOptions =
{:message => "is not a numerical value"}
- StripNonNumeric =
/[^-+e\d.]/im
- ValidNumericChars =
/\A[-+e\d.,\s]+\Z/im
Constants inherited from WhyValidationsSuckIn96::Validation
Instance Method Summary
Methods included from WhyValidationsSuckIn96::AttributeBasedValidation
#attribute, #attribute_value, #initialize
Methods inherited from WhyValidationsSuckIn96::Validation
#failed?, #has_run?, #initialize, #message, new_subclass, #passed?, #validates?
Constructor Details
This class inherits a constructor from WhyValidationsSuckIn96::AttributeBasedValidation
Instance Method Details
- (Object) validate
26 27 28 29 30 31 32 33 |
# File 'lib/whyvalidationssuckin96/macros/validates_numericality.rb', line 26 def validate super if [:only_integer] validate_as_integer else validate_as_float end end |