Author: grumbel
Date: 2007-11-04 13:36:03 +0100 (Sun, 04 Nov 2007)
New Revision: 3487

Modified:
   trunk/sexpr/schema.rb
Log:
- added min/max for Integer

Modified: trunk/sexpr/schema.rb
===================================================================
--- trunk/sexpr/schema.rb       2007-11-04 12:24:08 UTC (rev 3486)
+++ trunk/sexpr/schema.rb       2007-11-04 12:36:03 UTC (rev 3487)
@@ -205,6 +205,8 @@
   class IntegerType
     def initialize(reader)
       # FIXME: add min/max and other possible range restrictions here
+      @min = reader.read_integer("min")
+      @max = reader.read_integer("max")
     end
 
     def validate(sexpr)
@@ -214,7 +216,13 @@
         if not sexpr[0].is_a?(Integer) then
           Schema.report "#{sexpr.pos}: expected integer got #{sexpr[0].class}"
         else
-          # ok
+          if @max and sexpr[0].value > @max then
+            Schema.report "#{sexpr[0].pos}: integer out of range: [EMAIL 
PROTECTED] [EMAIL PROTECTED] int=#{sexpr[0].value}"
+          elsif @min and sexpr[0].value < @min then
+            Schema.report "#{sexpr[0].pos}: integer out of range: [EMAIL 
PROTECTED] [EMAIL PROTECTED] int=#{sexpr[0].value}"
+          else
+            # everything ok
+          end
         end
       end
     end



_______________________________________________
pingus-cvs mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/pingus-cvs

Reply via email to