Wichert Akkerman wrote:
That would be confusing though: I would expect the result of a method
that checks validaty to return something that evaluates to True if
everything is valid. Code like this just messes up my brain:

  if not zope.schema.validate(obj, IMySchema):
          print "Everything validates correctly!"

to me that is very non-intuitive and looks like the if condition is
incorrect.

Agreed. I prefer to name boolean methods with an "is" prefix. Then we would have

if zope.schema.isValid(obj, IMySchema):
    print 'valid'

and

if not zope.schema.isValid(...):
    print 'invalid'

That doesn't give any information about what is invalid though, I'd use a separate method for that. Perhaps something like "getValidationErrors".
--
Benji York
Senior Software Engineer
Zope Corporation
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to