self
accept to deserialize an instance of dynamic_type
for an attribute wuth static_type
?Uses whitelist
if not empty...
Check correct inheritance if check_subtypes
...
# Should `self` accept to deserialize an instance of `dynamic_type` for an attribute wuth `static_type`?
#
# Uses `whitelist` if not empty...
# Check correct inheritance if `check_subtypes`...
fun accept(dynamic_type: Text, static_type: nullable Text): Bool
do
if whitelist.not_empty and not whitelist.has(dynamic_type) then
errors.add new Error("Deserialization Error: '{dynamic_type}' not in whitelist")
return false
end
if static_type != null and check_subtypes then
var static_class = static_type.strip_nullable_and_params.to_s
var dynamic_class = dynamic_type.strip_nullable_and_params.to_s
if not class_inheritance_metamodel.has_edge(dynamic_class, static_class) then
errors.add new Error("Deserialization Error: `{dynamic_type}` is not a subtype of the static type `{static_type}`")
return false
end
end
return true
end
lib/serialization/safe.nit:62,2--83,4