def Validate(self, value):
    """Validate that value is correct type.

    Args:
      value: Value to validate.

    Returns:
      None if value is None, value if value is of correct type, converted
      value if the validator is configured to convert.

    Raises:
      ValidationError if value is not of the right type and validator
      is not configured to convert.
    """
    if not isinstance(value, self.expected_type):
      if value is not None and self.convert:
        try:
          return self.expected_type(value)
        except ValueError, e:
          raise ValidationError('Type conversion failed for value \'%s\'.'
                                % value,
                                e)
        except __HOLE__, e:
          raise ValidationError('Expected value of type %s, but got \'%s\'.'
                                % (self.expected_type, value))
      else:
        raise MissingAttribute('Missing value is required.')
    else:
      return value
dataset/ETHPy150Open CollabQ/CollabQ/.google_appengine/google/appengine/api/validation.py/Type.Validate