rails--rails/activemodel/test
John Hawthorn 68926798a5
Fix invalid string Decimal casting under ruby 2.4
In Ruby 2.4, BigDecimal(), as used by the Decimal cast, was changed so
that it will raise ArgumentError when passed an invalid string, in order
to be more consistent with Integer(), Float(), etc. The other numeric
types use ex. to_i and to_f.

Unfortunately, we can't simply change BigDecimal() to to_d. String#to_d
raises errors like BigDecimal(), unlike all the other to_* methods (this
should probably be filed as a ruby bug).

Instead, this simulates the existing behaviour and the behaviour of the
other to_* methods by finding a numeric string at the start of the
passed in value, and parsing that using BigDecimal().

See also
https://bugs.ruby-lang.org/issues/10286
3081a627ce
2017-02-24 19:41:23 -05:00
..
cases Fix invalid string Decimal casting under ruby 2.4 2017-02-24 19:41:23 -05:00
models Removed deprecated :tokenizer in the length validator 2016-10-10 20:29:24 -03:00
validators let Regexp#match? be globally available 2016-10-27 09:13:55 +02:00