Permalink
Browse files

OptionalFunction only calls its wrapped function if the data is non-None

  • Loading branch information...
1 parent d2ff8f8 commit 7c561ba97a1ebfa6351b67d6fc58aa812cd801ca jay groven committed Mar 23, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 jsonvalidator/__init__.py
View
5 jsonvalidator/__init__.py
@@ -87,8 +87,9 @@ class OptionalFunction(object):
def __init__(self, fn):
self.__fn = fn
- def __call__(self, *args, **kwargs):
- return self.__fn(*args, **kwargs)
+ def __call__(self, data):
+ if data is not None:
+ return self.__fn(data)
class JSONValidationError(Exception):
pass

0 comments on commit 7c561ba

Please sign in to comment.