def type_validator(property_type):
  """Create validator that requires specific type.

  Args:
    property_type: The type of the validator.

  Returns:
    Validator that only accepts values of a specific type.
  """
  def type_validator_impl(value):
    if not isinstance(value, property_type):
      raise TypeError('Property must be type %s' % property_type.__name__)
    return True
  return type_validator_impl