twistar.validation.presenceOf is broken
erikkaplun opened this issue · 1 comments
erikkaplun commented
class MyModel(DBObject):
field = None
MyModel.validatesPresenceOf('field')
assert MyModel().isValid() # succeeds
this is because presenceOf
has:
if getattr(obj, name, "") == "":
but should have:
if getattr(obj, name, None) is None:
optionally you can add checking for ""
depending on how you want to interpret empty strings:
if getattr(obj, name, None) in (None, ""):