code: def bytesIO(value,
              allow_empty = False,
              **kwargs):
      
      if not value and not allow_empty:
          raise errors.EmptyValueError('value (%s) was empty' % value)
      elif not value:
          return None
  
      if not isinstance(value, io.BytesIO):
          raise errors.NotBytesIOError('value (%s) is not a BytesIO, '
                                       'is a %s' % (value, type(value)))
  
      return value
docs: Validate that ``value`` is a :class:`BytesIO <python:io.BytesIO>` object.
  
      :param value: The value to validate.
  
      :param allow_empty: If ``True``, returns :obj:`None <python:None>` if
        ``value`` is empty. If ``False``, raises a
        :class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
        if ``value`` is empty. Defaults to ``False``.
      :type allow_empty: :class:`bool <python:bool>`
  
      :returns: ``value`` / :obj:`None <python:None>`
      :rtype: :class:`BytesIO <python:io.BytesIO>` / :obj:`None <python:None>`
  
      :raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
      :raises NotBytesIOError: if ``value`` is not a :class:`BytesIO <python:io.BytesIO>`
        object.