def wrap(self, value, session=None):
        ''' Validates that ``value`` is an ObjectId (or hex representation
            of one), then returns it '''
        self.validate_wrap(value)
        if isinstance(value, bytes) or isinstance(value, basestring):
            return ObjectId(value)
        return value