diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-01-16 17:56:37 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-01-16 17:56:37 +0000 |
commit | 6b6d3d4ad00c748e1906295b8e6ab0453d5d7727 (patch) | |
tree | 7d12f40540272e3e20c5fbf51983b31e9db6091d | |
parent | 5db7d0090b706704f92bb1d5c41f99d139a5ca50 (diff) | |
parent | 5e538690e65b7afbc97ab27816f2881b440cdd5b (diff) | |
download | rabbitmq-server-6b6d3d4ad00c748e1906295b8e6ab0453d5d7727.tar.gz |
stable to default
-rw-r--r-- | src/rabbit_policy.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl index 2c997f16..fa13c5dd 100644 --- a/src/rabbit_policy.erl +++ b/src/rabbit_policy.erl @@ -218,10 +218,13 @@ validation(_Name, Terms) when is_list(Terms) -> rabbit_registry:lookup_all(policy_validator)), [] = dups(Keys), %% ASSERTION Validators = lists:zipwith(fun (M, K) -> {M, a2b(K)} end, Modules, Keys), - {TermKeys, _} = lists:unzip(Terms), - case dups(TermKeys) of - [] -> validation0(Validators, Terms); - Dup -> {error, "~p duplicate keys not allowed", [Dup]} + case is_proplist(Terms) of + true -> {TermKeys, _} = lists:unzip(Terms), + case dups(TermKeys) of + [] -> validation0(Validators, Terms); + Dup -> {error, "~p duplicate keys not allowed", [Dup]} + end; + false -> {error, "definition must be a dictionary: ~p", [Terms]} end; validation(_Name, Term) -> {error, "parse error while reading policy: ~p", [Term]}. @@ -249,3 +252,5 @@ validation0(Validators, Terms) -> a2b(A) -> list_to_binary(atom_to_list(A)). dups(L) -> L -- lists:usort(L). + +is_proplist(L) -> length(L) =:= length([I || I = {_, _} <- L]). |