Class: StrictIntegerType

Inherits:
ActiveModel::Type::Integer
  • Object
show all
Defined in:
app/types/strict_integer_type.rb

Constant Summary collapse

NUMERIC_RE =
/\A\s*(?:\-?)(\d)+\s*\z/

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object


4
5
6
7
8
9
# File 'app/types/strict_integer_type.rb', line 4

def cast(value)
  if value.is_a?(String) && NUMERIC_RE.match(value).nil?
    return value
  end
  super
end