Sha256: 77c24c0415b2bc0edc61150fd1d1eb9061f9484f1cbec7d46ef5767d6743cadb
Contents?: true
Size: 365 Bytes
Versions: 2
Compression:
Stored size: 365 Bytes
Contents
module Validatable class ValidatesNumericalityOf < ValidationBase #:nodoc: option :only_integer def valid?(instance) value = instance.send(self.attribute).to_s regex = self.only_integer ? /\A[+-]?\d+\Z/ : /^\d*\.{0,1}\d+$/ not (value =~ regex).nil? end def message super || "must be a number" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validatable-1.3.0 | lib/validations/validates_numericality_of.rb |
validatable-1.3.2 | lib/validations/validates_numericality_of.rb |