anchor.diff:           name/1,
            id/1,
            org_id/1,
  -         type_name/1
  +         type_name/1,
  +         assemble_organization_ejson/1,
  +         parse_binary_json/1
           ]).
   
   -mixin([
  
positive.code: list_query() ->
      list_organizations.
  
  bulk_get_query() ->
      erlang:error(not_implemented).
  
  
negative.code: 
  type_name(#oc_chef_organization{}) ->
      organization.
  
  %%
  %% TODO: This was copy-pasta'd from chef_regex, reunite someday (see also oc_chef_container)
  %%
  %% The name regex should limit to some short length. Nginx default is 8k. (large_client_header_buffers)
  %% but we probably for sanity's sake want something less. 255 seems reasonable, but we probably should dig deeper.
  %% For reference, I've succesfully created orgs of 900+ character lengths in hosted, but failed with 1000.
  %% Probably have to be able to handle api.opscode.us/<ORGNAME>/environments/default in 1k?)
  %%
  %% We use [a-z] instead of [:lower:] because the latter can change meaning if we set PCRE_UCP when compiling the regex.
  %%
  %% The org name is stricter than the lb allows (right now; it doesn't block upper/digit/-_ for first character)
  %% This strictness matches the previous ruby implementation, except that it didn't limit the length.
  -define(ORG_NAME_REGEX, "[a-z0-9][a-z0-9_-]{0,254}").
  %%
  %% Full name is free text, except that it must start with nonspace.
  %%
  -define(FULL_NAME_REGEX, "\\S.{0,1022}"). 
  -define(ANCHOR_REGEX(Regex), "^" ++ Regex ++ "$").
  
  generate_regex(Pattern) ->
    {ok, Regex} = re:compile(Pattern),
    Regex.
  
  generate_regex_msg_tuple(Pattern, Message) ->
    Regex = generate_regex(Pattern),
    {Regex, Message}.
  
  regex_for(org_name) ->
      generate_regex_msg_tuple(?ANCHOR_REGEX(?ORG_NAME_REGEX),
                               <<"Malformed org name.  Must only contain A-Z, a-z, 0-9, _, or -">>);
  regex_for(org_full_name) ->
      generate_regex_msg_tuple(?ANCHOR_REGEX(?FULL_NAME_REGEX),
                               <<"Malformed org full name.  Must only contain A-Z, a-z, 0-9, _, or -">>).
  