def Validate(func, value):
  """Raises a ValueError if the value doesn't cause the given function to return true"""
  if func(value):
    return value
  raise ValueError("%r: Invalid value %r" % (func, value))