anchor.diff:  
   -include_lib("webmachine/include/webmachine.hrl").
   
  +-include_lib("ej/include/ej.hrl").
  +
   -include_lib("eunit/include/eunit.hrl").
   
   init(Config) ->
  
positive.code:     Body = wrq:req_body(Req),
      JobJson = jiffy:decode(Body),
  
      validate_keys(JobJson),
      validate_command(ej:get({<<"command">>}, JobJson)),
      validate_nodes(ej:get({<<"nodes">>}, JobJson)).
  
  validate_command(Command) ->
      case Command of
          undefined ->
              throw(bad_command);
          _ ->
              true
      end.
  
  validate_nodes(Nodes) ->
      if
          length(Nodes) =:= 0 -> throw(no_nodes);
          true -> true
      end.
  
  
negative.code:             Msg = <<"invalid command supplied">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State};
          throw:bad_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};
          throw:bad_type_quorum ->
              Msg = <<"invalid type supplied for quorum (expected a number)">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State};
          throw:bad_type_run_timeout ->
              Msg = <<"invalid type supplied for run_timeout (expected a number)">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State};
          throw:unknown_validation_error ->
              Msg = <<"an unknown validation error has occurred">>,
              Req1 = wrq:set_resp_body(jiffy:encode({[{<<"error">>, Msg}]}), Req),
              {{halt, 400}, Req1, State}
      end.
  