<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -27,13 +27,16 @@ module DataMapper
           return true if value =~ /\A[+-]?\d+\z/
           error_message ||= '%s must be an integer'.t(Extlib::Inflection.humanize(@field_name))
         else
+          # FIXME: if precision and scale are not specified, can we assume that it is an integer?
           if precision &amp;&amp; scale
-            if precision == scale
-              return true if value =~ /\A[+-]?(?:0(?:\.\d{1,#{scale}})?)\z/
-            elsif scale == 0
+            if precision &gt; scale &amp;&amp; scale &gt; 0
+              return true if value =~ /\A[+-]?(?:\d{1,#{precision - scale}}|\d{0,#{precision - scale}}\.\d{1,#{scale}})\z/
+            elsif precision &gt; scale &amp;&amp; scale == 0
               return true if value =~ /\A[+-]?(?:\d{1,#{precision}}(?:\.0)?)\z/
+            elsif precision == scale
+              return true if value =~ /\A[+-]?(?:0(?:\.\d{1,#{scale}})?)\z/
             else
-              return true if value =~ /\A[+-]?(?:\d{1,#{precision - scale}}|\d{0,#{precision - scale}}\.\d{1,#{scale}})\z/
+              raise ArgumentError, &quot;Invalid precision #{precision.inspect} and scale #{scale.inspect} for #{field_name} (value: #{value.inspect} #{value.class})&quot;
             end
           else
             return true if value =~ /\A[+-]?(?:\d+|\d*\.\d+)\z/</diff>
      <filename>dm-validations/lib/dm-validations/numeric_validator.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e602a514b011d7d510950414b45ce5b9309c4012</id>
    </parent>
  </parents>
  <author>
    <name>Dan Kubb</name>
    <email>dan.kubb@autopilotmarketing.com</email>
  </author>
  <url>http://github.com/sam/dm-more/commit/47b8a82b187f95dfb4702ebd0b99903fcf2daf44</url>
  <id>47b8a82b187f95dfb4702ebd0b99903fcf2daf44</id>
  <committed-date>2008-06-24T08:57:41-07:00</committed-date>
  <authored-date>2008-06-24T08:55:58-07:00</authored-date>
  <message>Updated numeric validator to raise if precision and scale are invalid</message>
  <tree>ea62155c04ac75f2762f0fc35017e816d7a5d72c</tree>
  <committer>
    <name>Dan Kubb</name>
    <email>dan.kubb@autopilotmarketing.com</email>
  </committer>
</commit>
