Skip to content

Commit

Permalink
KAZOO-2837: specs
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Aug 27, 2014
1 parent 51e7c48 commit dbe1972
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/whistle-1.0.0/src/wh_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ has_any(Prop, Headers) ->

%% checks Prop against a list of values to ensure known key/value pairs are correct (like Event-Category
%% and Event-Name). We don't care if a key is defined in Values and not in Prop; that is handled by has_all/1
-spec values_check(wh_proplist(), wh_proplist()) -> boolean().
values_check(Prop, Values) ->
lists:all(fun(Value) -> values_check_all(Prop, Value) end, Values).

-spec values_check_all(wh_proplist(), {_, _}) -> boolean().
values_check_all(Prop, {Key, Vs}) when is_list(Vs) ->
case props:get_value(Key, Prop) of
'undefined' -> 'true'; % isn't defined in Prop, has_all will error if req'd
Expand All @@ -420,9 +422,13 @@ values_check_all(Prop, {Key, V}) ->

%% checks Prop against a list of {Key, Fun}, running the value of Key through Fun, which returns a
%% boolean.
-type typecheck() :: {ne_binary(), fun((_) -> boolean())}.
-type typechecks() :: [typecheck(),...] | [].
-spec type_check(wh_proplist(), typechecks()) -> boolean().
type_check(Prop, Types) ->
lists:all(fun(Type) -> type_check_all(Prop, Type) end, Types).

-spec type_check_all(wh_proplist(), typecheck()) -> boolean().
type_check_all(Prop, {Key, Fun}) ->
case props:get_value(Key, Prop) of
%% isn't defined in Prop, has_all will error if req'd
Expand Down

0 comments on commit dbe1972

Please sign in to comment.