title: How would you handle creating a response for a method that checks if an object is valid?
body: <p>Lets say I have a Model in my models.py that stores financial transactions. The model has a method called is_valid() which basically checks that the object adheres to a bunch of business logics.</p>
  
  <p>This method has now got quite long, it does about 20 checks on the object and looks something like this:</p>
  
  <pre><code>    def is_valid(self):
          if self.something is something:
              return false
          if self.something_else is something:
              return false
          ...
          return true
  </code></pre>
  
  <p>So far this has worked great, but I've now got to the stage where I no longer need to just know if an object is valid, but if it's not valid I need to know which check it failed. So something like:</p>
  
  <pre><code>    def is_valid(self):
          if self.something is something:
              return error1
          if self.something_else is something:
              return error2
          ...
          return true
  </code></pre>
  
  <p>But, if the object has failed multiple checks then I'd want to know all the checks it has failed.</p>
  
  <p>What would be the most clean way of handling this?</p>
  
  <p>My code also has lots of lines that check is_valid() returns true, so ideally it would still return true if the object is valid, but if not valid then it would let me know which conditions it failed.</p>