anchor.diff:  
   -include_lib("webmachine/include/webmachine.hrl").
   
  +-include_lib("ej/include/ej.hrl").
  +
   -include_lib("eunit/include/eunit.hrl").
   
   init(Config) ->
  
positive.code:             Msg = <<"invalid command supplied">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State};
          throw:no_nodes ->
              Msg = <<"at least one node must be supplied">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State};
          throw:bad_key ->
              Msg = <<"invalid key supplied">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State}
      end.
  
negative.code:     Body = wrq:req_body(Req),
      JobJson = jiffy:decode(Body),
  
      validate_body(JobJson).
  
  validate_body(Json) ->
      Spec = {[{<<"command">>, string},
               {<<"nodes">>, array},
               {{opt, <<"run_timeout">>}, number},
               {{opt, <<"quorum">>}, number}]},
  
      case ej:valid(Spec, Json) of
          ok ->
              %% Make sure there are no extra keys
              validate_keys(Json),
              %% Make sure there is at least one node in the array
              validate_nodes(ej:get({<<"nodes">>}, Json)),
              ok;
          #ej_invalid{type = Type, key = Key} ->
              case {Type, Key} of
                  {_, <<"nodes">>} -> throw(bad_nodes);
                  {_, <<"command">>} -> throw(bad_command);
                  {json_type, <<"quorum">>} -> throw(bad_type_quorum);
                  {json_type, <<"run_timeout">>} -> throw(bad_type_run_timeout);
                  {_T, _K} -> throw(unknown_validation_error)
              end
                      
      end.
  
  validate_nodes(Nodes) ->
      if
          length(Nodes) =:= 0 -> throw(bad_nodes);
          true -> true
      end.
  
  