Validates the document object with current values, always called
        within :meth:`couchbasekit.document.Document.save` method.

        :returns: Always True, or raises
            :exc:`couchbasekit.errors.StructureError` exception.
        :raises: :exc:`couchbasekit.errors.StructureError` if
            any validation problem occurs.

def validate(self):
        """Validates the document object with current values, always called
        within :meth:`couchbasekit.document.Document.save` method.

        :returns: Always True, or raises
            :exc:`couchbasekit.errors.StructureError` exception.
        :raises: :exc:`couchbasekit.errors.StructureError` if
            any validation problem occurs.
        """
        # __key_field__ value must be provided if defined
        if self.__key_field__ and self.__key_field__ not in self:
            raise self.StructureError(msg="Key field '%s' is defined "
                                          "but not provided." % self.__key_field__)
        # check the required fields first
        for required in self.required_fields:
            log.debug("required_field: %s" % required)
            if (required not in self and required not in self.default_values) or \
               (required in self and self[required] is None):
                raise self.StructureError(
                    msg = "Required field for '%s' is missing." % required
                )
        return self._validate(self.structure, self)