code: def check(self, spec, data):
          '''Given a mongo-style spec and some data or python object,
          check whether the object complies with the spec. Fails eagerly.
          '''
          path_eval = self.path_eval
          for keypath, specvalue in spec.items():
              if keypath.startswith('$'):
                  optext = keypath
                  checkable = data
                  args = (optext, specvalue, checkable)
                  generator = self.dispatch_operator(*args)
              else:
                  try:
                      checkable = path_eval(data, keypath)
                  except self.InvalidPath:
                      # The spec referenced an item or attribute that
                      # doesn't exist. Fail!
                      return False
                  generator = self.dispatch_literal(specvalue, checkable)
              for result in generator:
                  if not result:
                      return False
          return Truf check(self, spec, data):
          '''Given a mongo-style spec and some data or python object,
          check whether the object complies with the spec. Fails eagerly.
          '''
          path_eval = self.path_eval
          for keypath, specvalue in spec.items():
              if keypath.startswith('$'):
                  optext = keypath
                  checkable = data
                  args = (optext, specvalue, checkable)
                  generator = self.dispatch_operator(*args)
              else:
                  try:
                      checkable = path_eval(data, keypath)
                  except self.InvalidPath:
                      # The spec referenced an item or attribute that
                      # doesn't exist. Fail!
                      return False
                  generator = self.dispatch_literal(specvalue, checkable)
              for result in generator:
                  if not result:
                      return False
          return True
docs: Given a mongo-style spec and some data or python object,
          check whether the object complies with the spec. Fails eagerly.