Skip to content

Commit

Permalink
Merge branch 'master' of github.com:doncatnip/kanone
Browse files Browse the repository at this point in the history
  • Loading branch information
doncatnip committed Dec 19, 2012
2 parents 61d1055 + 24e76ce commit 8833a49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/kanone/validator/check.py
Expand Up @@ -178,3 +178,33 @@ def on_value(self, context, value):

return value


@messages\
( fail="Value must lower or equal to %(max)s"
)
class Max( Validator ):

def setParameters( self, max ):
self.max = max

def on_value(self, context, value):
if value > self.max:
raise Invalid( value, self, max=self.max )

return value



@messages\
( fail="Value must greater or equal to %(min)s"
)
class Min( Validator ):

def setParameters( self, min ):
self.min = min

def on_value(self, context, value):
if value < self.min:
raise Invalid( value, self, min=self.min )

return value
2 changes: 0 additions & 2 deletions src/kanone/validator/schema.py
Expand Up @@ -393,7 +393,6 @@ def appendSubValidators( self, subValidators ):

def validate(self, context, value):
fieldcontext = self.getField( context, self.path )
print(('fieldcontext: %s' % (fieldcontext,)))
result = PASS

if not self.useResult:
Expand All @@ -405,7 +404,6 @@ def validate(self, context, value):
except Invalid:
result = PASS

print(('fieldcontext.value: %s' % (result) ))
if self.validator is not None:
if result is not PASS:
result = self.validator.validate( fieldcontext, result )
Expand Down

0 comments on commit 8833a49

Please sign in to comment.