提交 d2992818 编写于 作者: C Carlos Antonio da Silva

Simplify number parsing logic in numericality validation

上级 f70e30ec
......@@ -56,16 +56,9 @@ def validate_each(record, attr_name, value)
protected
def parse_raw_value_as_a_number(raw_value)
case raw_value
when /\A0[xX]/
nil
else
begin
Kernel.Float(raw_value)
rescue ArgumentError, TypeError
nil
end
end
Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/
rescue ArgumentError, TypeError
nil
end
def parse_raw_value_as_an_integer(raw_value)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册