in pyre_extensions/safe_json.py [0:0]
def _validate_value(value: object, target_type: Type[object]) -> None:
if target_type is Any:
return
elif _is_list(target_type):
_validate_list(value, cast(Type[List[object]], target_type))
elif _is_dictionary(target_type):
_validate_dictionary(value, cast(Type[Dict[object, object]], target_type))
elif _is_typed_dictionary(target_type):
_validate_typed_dictionary(value, target_type)
elif is_optional_type(target_type):
if value is None:
return
_validate_value(value, get_args(target_type)[0])
else:
if target_type not in [int, float, str, bool]:
raise InvalidJson(f"Invalid value type {target_type}")
if not isinstance(value, target_type):
raise InvalidJson(f"`{value}` is not a {target_type}")