Update src/aeserialization.erl with duplicates check
From code review Co-authored-by: Radosław Rowicki <35342116+radrow@users.noreply.github.com>
This commit is contained in:
parent
05c4f87619
commit
893ebb69f6
@ -129,6 +129,7 @@ decode_field(#{items := Items}, List) when length(List) =:= length(Items) ->
|
|||||||
Zipped = lists:zip(Items, List),
|
Zipped = lists:zip(Items, List),
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({{K, Type}, V}, Map) ->
|
fun({{K, Type}, V}, Map) ->
|
||||||
|
maps:is_key(K, Map) andalso error(badarg, duplicate_field),
|
||||||
Map#{ K => decode_field(Type, V) }
|
Map#{ K => decode_field(Type, V) }
|
||||||
end, #{}, Zipped);
|
end, #{}, Zipped);
|
||||||
decode_field(Type, List) when length(List) =:= tuple_size(Type) ->
|
decode_field(Type, List) when length(List) =:= tuple_size(Type) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user