0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Exit with required error when checking a constrait and key does not exist.

This commit is contained in:
Ali Farhadi 2021-02-13 23:14:42 +01:00
parent 8795233c57
commit 91b28d6109

View file

@ -991,7 +991,12 @@ filter([], Map, Errors) ->
_ -> {error, Errors}
end;
filter([{Key, Constraints}|Tail], Map, Errors) ->
filter_constraints(Tail, Map, Errors, Key, maps:get(Key, Map), Constraints);
case maps:find(Key, Map) of
{ok, Value} ->
filter_constraints(Tail, Map, Errors, Key, Value, Constraints);
error ->
filter(Tail, Map, Errors#{Key => required})
end;
filter([{Key, Constraints, Default}|Tail], Map, Errors) ->
case maps:find(Key, Map) of
{ok, Value} ->