anchor.diff:                          FoundOldRecord -> {false, FoundOldRecord}
                       end
               end,
  -            HookResult = case boss_record_lib:run_before_hooks(Record, IsNew) of
  -                ok -> {ok, Record};
  -                {ok, Record1} -> {ok, Record1};
  -                {error, Reason} -> {error, Reason}
  -            end,
  -            case HookResult of
  -                {ok, PossiblyModifiedRecord} ->
  -                    case db_call({save_record, PossiblyModifiedRecord}) of
  -                        {ok, SavedRecord} ->
  -                            boss_record_lib:run_after_hooks(OldRecord, SavedRecord, IsNew),
  -                            {ok, SavedRecord};
  +            case validate_record_constraints(Record, IsNew) of
  +                ok ->
  +                    HookResult = case boss_record_lib:run_before_hooks(Record, IsNew) of
  +                                     ok -> {ok, Record};
  +                                     {ok, Record1} -> {ok, Record1};
  +                                     {error, Reason} -> {error, Reason}
  +                                 end,
  +                    case HookResult of
  +                        {ok, PossiblyModifiedRecord} ->
  +                            case db_call({save_record, PossiblyModifiedRecord}) of
  +                                {ok, SavedRecord} ->
  +                                    boss_record_lib:run_after_hooks(OldRecord, SavedRecord, IsNew),
  +                                    {ok, SavedRecord};
  +                                Err -> Err
  +                            end;
                           Err -> Err
                       end;
                   Err -> Err
  
positive.code:         execute/2,
          transaction/1,
          validate_record/1,
          validate_record_types/1,
          type/1,
          data_type/2]).
  
negative.code: -export([start/1, stop/0]).
  
  -export([
          find/1,
          find/2,
          find/3,
          find_first/2,
          find_first/3,
          find_last/2,
          find_last/3,
          count/1,
          count/2,
          counter/1,
          incr/1,
          incr/2,
          delete/1,
          save_record/1,
          push/0,
          pop/0,
          depth/0,
  