anchor.diff:                User,
                 Defaults).
   
  --spec validate_user(ejson_term(), user_action()) -> {ok, ejson_term()}. % or throw
  -validate_user(User, create) ->
  -  case chef_json_validator:validate_json_by_regex_constraints(User, ?VALIDATION_CONSTRAINTS) of
  -    ok -> {ok, User};
  -    Bad -> throw(Bad)
  +%%-spec validate_user(ejson_term(), ejson_term()) -> {ok, ejson_term()}. % or throw
  +validate_user(User, Spec) ->
  +  case ej:valid(Spec, User) of
  +    ok ->
  +      {ok, User};
  +    BadSpec ->
  +      throw(BadSpec)
     end.
   
   %% @doc Add public and private key data to `UserEjson'. This function infers
  
positive.code: 
  %% @doc Convert a binary JSON string representing a Chef User into an
  %% EJson-encoded Erlang data structure.
  -spec parse_binary_json( binary(), user_action() ) -> {ok, ejson_term() }. % or throw
  parse_binary_json(Bin, Action) ->
    User0 = ejson:decode(Bin),
    User1 = set_default_values(User0, ?DEFAULT_FIELD_VALUES),
    validate_user(User1, Action).
  
  set_default_values(User, Defaults) ->
    lists:foldl(fun({Key, Default}, Current) ->
  
negative.code: 
  %% fields:
   %% username/name - in webui, name has _ inserted for , (periods) so should check that there are no periods in the name here
   %% password - no default -
   %%   cannot be blank, must be 6 chars
   %% openid - default is none - no restrictions on what it can be set to
  
  -define(DEFAULT_FIELD_VALUES,
          [
            {<<"openid">>, null},
            {<<"admin">>, false}
          ]).
  
  user_spec() ->
    {[
      {<<"name">>, {string_match, username_validation_regex()}},
      {<<"password">>, {string_match, password_validation_regex()}},
      {{opt,<<"admin">>}, boolean},
      {{opt, <<"openid">>}, string}
     ]}.
  
  username_validation_regex() ->
      UsernamePattern = <<"^[a-z0-9\-_]+$">>,
      {ok, UsernameRegex} = re:compile(UsernamePattern),
      {UsernameRegex, UsernamePattern}.
  
  password_validation_regex() ->
    PasswordPattern = <<".{6,}">>,
    {ok, PasswordRegex} = re:compile(PasswordPattern),
    {PasswordRegex, PasswordPattern}.
  
  assemble_user_ejson(#chef_user{username = Name,
                                 public_key = PubKey,
  