code: def Uuid(to_uuid=True):
      
      @wraps(Uuid)
      def built(value):
          invalid = Error("Not a valid UUID")
  
          if isinstance(value, uuid.UUID):
              return value
          elif not isinstance(value, six.string_types):
              raise invalid
  
          try:
              as_uuid = uuid.UUID(value)
          except (ValueError, AttributeError) as e:
              raise invalid
  
          if to_uuid:
              return as_uuid
          return value
      return built
docs: Creates a UUID validator. Will raise an error for non-string types and
      non-UUID values.
  
      The given value will be converted to an instance of ``uuid.UUID`` unless
      ``to_uuid`` is ``False``.