aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/validations/numericality.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb
index 126a87ac6e..b9ae42fd39 100644
--- a/activemodel/lib/active_model/validations/numericality.rb
+++ b/activemodel/lib/active_model/validations/numericality.rb
@@ -86,13 +86,17 @@ module ActiveModel
def parse_raw_value_as_a_number(raw_value)
return raw_value.to_i if is_integer?(raw_value)
- Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/
+ Kernel.Float(raw_value) unless is_hexadecimal_literal?(raw_value)
end
def is_integer?(raw_value)
/\A[+-]?\d+\z/ === raw_value.to_s
end
+ def is_hexadecimal_literal?(raw_value)
+ /\A0[xX]/ === raw_value
+ end
+
def filtered_options(value)
filtered = options.except(*RESERVED_OPTIONS)
filtered[:value] = value