def validate(object)
      # Handle nil case.
      if object.nil?
        if allow_nil?
          self.sanitized_object = nil
          return true
        else
          raise ValidationError, "object is nil but this #{self.class.name} does not allow nil"
        end
      end
      @schema.validate(object)
      self.sanitized_object = sanitize(@schema.sanitized_object)
      true
    rescue ValidationError => e
      # Reset sanitized object.
      self.sanitized_object = nil
      raise e
    end
def validate(object)
      # Handle nil case.
      if object.nil?
        if allow_nil?
          self.sanitized_object = nil
          return true
        else
          raise ValidationError, "object is nil but this #{self.class.name} does not allow nil"
        end
      end
      @schema.validate(object)
      self.sanitized_object = sanitize(@schema.sanitized_object)
      true
    rescue ValidationError => e
      # Reset sanitized object.
      self.sanitized_object = nil
      raise e
    end
Overloaded methods (see {Schema#validate}).