title: How to use dependency injection to inject IO.gets input in Elixir?
body: <p>Suppose I have a function that validates user's input and then output something:</p>
  
  <pre><code>def set_name(user_input) do
  
    case !InputValidators.empty_input?(user_input) do
        true -&gt; user_input
        false -&gt;
          display_error(error)
          set_name(user_input)
    end
  end
  </code></pre>
  
  <p>I want to be able to use IO to capture user input but I don't want to call IO.gets inside the function. I read about using dependency inject but I'm not sure how I'll go about using it in situation like this. </p>