anchor.diff:  %% @end
   parse_binary_json(Bin, ReqName, Defaults) ->
       Client = chef_json:decode_body(Bin),
  -    NewClient = case Defaults of
  +    Client1 = set_name_values(Client),
  +    Client2 = case Defaults of
                       not_found ->
  -                        set_default_values(Client);
  +                        set_default_values(Client1);
                       Values ->
  -                        set_default_values(Client, Values)
  +                        set_default_values(Client1, Values)
                   end,
  -    {Name, FinalClient} = set_name_values(NewClient, ReqName),
  -    valid_name(Name),
  +    {Name, FinalClient} = validate_name_or_rename(Client2, ReqName),
  +    valid_name_format(Name),
       validate_client(FinalClient, Name).
   
   client_spec(Name) ->
  
positive.code:         Bad -> throw(Bad)
      end.
  
  valid_name(Name) ->
      {Regex, Msg} = chef_regex:regex_for(client_name),
      case re:run(Name, Regex) of
          nomatch ->
  
negative.code:                 Client,
                  Defaults).
  
  set_name_values(Client) ->
      % Since either name or clientname is required (but not both), if only one is
      % passed, we will use it to set the other one
      Name = ej:get({<<"name">>}, Client),
      ClientName = ej:get({<<"clientname">>}, Client),
      case {Name, ClientName} of
          {Name, Name} ->
              Client;
          {Name, undefined} ->
              ej:set({<<"clientname">>}, Client, Name);
          {undefined, ClientName} ->
              ej:set({<<"name">>}, Client, ClientName);
          {_, _} ->
              throw({client_name_mismatch})
      end.
  
  validate_name_or_rename(Client, ReqName) ->
      Name = ej:get({<<"name">>}, Client),
      case {Name, ReqName} of
          {undefined, undefined} ->
              throw({both_missing, <<"name">>, <<"clientname">>});
          {undefined, _} ->
              {ReqName, ej:set({<<"name">>}, ej:set({<<"clientname">>},
                                                    Client, ReqName), ReqName)};
          {Name, undefined} ->
              % This is a POST, nothing to do here
              {Name, Client};
          {Name, Name} ->
              % This is a regular PUT, nothing to do here
              {Name, Client};
          {Name, _} ->
              % This is a rename; we need to check for existing records
              {ReqName, ej:set({<<"name">>}, ej:set({<<"clientname">>},
                                                    Client, ReqName), ReqName)}
      end.
  
  validate_client(Client, Name) ->
  