Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ItemValidator(object):
- def __init__(self, items, item=None):
- self.items = items
- self.item = item
- def validate(self):
- if self.item:
- if self.item.color = "Green" and Item("Red") in self.items: # or something like that
- raise MyGreenValidationError
- return True
- >>> f = Foo()
- >>> item = Item("Green")
- >>> i = ItemValidator(f.items, item=item)
- >>> if i.validate():
- >>> f.items.add(item)
Advertisement
Add Comment
Please, Sign In to add comment