anchor.diff:                 end,
       validate_range(Name, Min, Max, ErrorFun, State).
   
  -validate_range(Name, Min, Max, ErrorFun, {_, InList, _} = State) ->
  -    Value = proplists:get_value(Name, InList),
  -    case Value of
  -        undefined ->
  -            State;
  -        _ ->
  -            case (Value >= Min) andalso (Value =< Max) of
  -                true ->
  -                    State;
  -                false ->
  -                    return_error(Name, ErrorFun(Name, Min, Max), State)
  -            end
  -    end.
  +validate_range(Name, Min, Max, ErrorFun, State) ->
  +    validate_by_fun(fun (Value) ->
  +                            case (Value >= Min) andalso (Value =< Max) of
  +                                true ->
  +                                    ok;
  +                                false ->
  +                                    {error, ErrorFun(Name, Min, Max)}
  +                            end
  +                    end, Name, State).
   
   validate_unsupported_params({OutList, InList, Errors}) ->
       NewErrors = [{list_to_binary(Key),
  
positive.code:          validate_has_params/1,
           validate_memory_quota/2,
           validate_any_value/2,
           execute_if_validated/3]).
  
  %% used by parse_validate_number
  
negative.code:     {lists:keydelete(atom_to_list(Name), 1, OutList), InList,
       [{Name, iolist_to_binary(Error)} | Errors]}.
  
  validate_by_fun(Fun, Name, {_, InList, _} = State) ->
      Value = proplists:get_value(Name, InList),
      case Value of
          undefined ->
              State;
          _ ->
              case Fun(Value) of
                  ok ->
                      State;
                  {error, Error} ->
                      return_error(Name, Error, State)
              end
      end.
  
  validate_boolean(Name, {OutList, _, _} = State) ->
      Value = proplists:get_value(atom_to_list(Name), OutList),
      case Value of
  