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: 
  %% fields:
   %% username/name - in webui, name has _ inserted for , (periods) so should check that there are no periods in the name here
   %% salt - no default - generated in webui
   %% password - no default -
   %%   cannot be blank, must be 6 chars - encorced in webui
   %%   it is also encrypted in webui, so might not feasible to verify restrictions here
   %% openid - default is none - no restrictions on what it can be set to
  
  -define(DEFAULT_FIELD_VALUES,
          [
            {<<"openid">>, null},
            {<<"admin">>, <<"false">>}
          ]).
  
  -define(VALIDATION_CONSTRAINTS,
          [
            %%{<<"name">>, {match, "" }},   At the least should be non-null
            %%{<<"password">>, {match, "" }}, At the least should be non-null
            {<<"admin">>, {match, "^true$|^false$"}}
          ]).
  
  -type user_action() :: create.
  
  assemble_user_ejson(#chef_user{username = Name,
                                 public_key = PubKey,
  
negative.code: -module(chef_user).
  
  -export([assemble_user_ejson/2,
           parse_binary_json/1,
           set_key_pair/3,
           set_public_key/2]).
  
  