anchor.diff:  	false;
   validate({_, Topic}) when length(Topic) > ?MAX_LEN ->
   	false;
  -validate({subscribe, Topic}) when is_list(Topic) ->
  -	valid(words(Topic));
  -validate({publish, Topic}) when is_list(Topic) ->
  -	Words = words(Topic),
  -	valid(Words) and (not include_wildcard(Words)).
  +validate({Type, Topic}) when is_list(Topic) ->
  +	valid(Type, words(Topic)).
   
   triples(S) when is_list(S) ->
   	triples(S, []).
  
positive.code: unword([Word|Rest], Acc) ->
      unword(Rest, [$/, Word|Acc]).
  
  valid([""|Words]) -> valid2(Words); %% leading '/'
  valid(Words) -> valid2(Words).
  
  valid2([""]) -> true; %% allow trailing '/'
  %valid2([""|_Words]) -> false; %% forbid '//'
  valid2(["#"|Words]) when length(Words) > 0 -> false;
  valid2([_|Words]) -> valid2(Words);
  valid2([]) -> true.
  
  include_wildcard([]) -> false;
  include_wildcard(["#"|_T]) -> true;
  include_wildcard(["+"|_T]) -> true;
  include_wildcard([_H|T]) -> include_wildcard(T).
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  
negative.code:     true = validate({subscribe, "test/topic/+"}),
      true = validate({subscribe, "+/+/+/+/+/+/+/+/+/+/test"}),
  
      false = validate({publish, "test/#-"}),
      false = validate({publish, "test/+-"}),
  	false = validate({subscribe, "a/#/c"}),
      false = validate({subscribe, "#testtopic"}),
      false = validate({subscribe, "testtopic#"}),
      false = validate({subscribe, "+testtopic"}),
      false = validate({subscribe, "testtopic+"}),
      false = validate({subscribe, "#testtopic/test"}),
      false = validate({subscribe, "testtopic#/test"}),
      false = validate({subscribe, "+testtopic/test"}),
      false = validate({subscribe, "testtopic+/test"}),
      false = validate({subscribe, "/test/#testtopic"}),
      false = validate({subscribe, "/test/testtopic#"}),
      false = validate({subscribe, "/test/+testtopic"}),
      false = validate({subscribe, "/testtesttopic+"}).
  
  
  
  -endif.
  