[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3487 - trunk/sexpr
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3487 - trunk/sexpr |
Date: |
Sun, 4 Nov 2007 13:36:03 +0100 |
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:
address@hidden address@hidden int=#{sexpr[0].value}"
+ elsif @min and sexpr[0].value < @min then
+ Schema.report "#{sexpr[0].pos}: integer out of range:
address@hidden address@hidden int=#{sexpr[0].value}"
+ else
+ # everything ok
+ end
end
end
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3487 - trunk/sexpr,
grumbel at BerliOS <=