code: def uuid(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 isinstance(value, uuid_.UUID):
          return value
  
      try:
          value = uuid_.UUID(value)
      except ValueError:
          raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
  
      return value
docs: Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
  
      :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`` coerced to a :class:`UUID <python:uuid.UUID>` object /
        :obj:`None <python:None>`
      :rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
  
      :raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
      :raises CannotCoerceError: if ``value`` cannot be coerced to a
        :class:`UUID <python:uuid.UUID>`