title: Why does Ecto's `cast` not convert an integer to a string?
body: <p>I have an Ecto schema that includes <code>field :owned_by_id, :string</code>. I declared the field a string because I need to support values like "abc123" as well as values like "123".</p>
  
  <p>The <a href="https://hexdocs.pm/ecto/Ecto.Changeset.html#cast/3" rel="nofollow noreferrer">docs for cast/3</a> say:</p>
  
  <blockquote>
    <p>The second argument is a map of params that are cast according to the type information from <code>data</code>.</p>
  </blockquote>
  
  <p>In my module, I define <code>changeset</code> like:</p>
  
  <pre><code>def changeset(struct, params \\ %{}) do
    cast(struct, params, [:owned_by_id])
  end
  </code></pre>
  
  <p>When I do this:</p>
  
  <pre><code>MyModule.changeset(%MyModule{}, %{owned_by_id: 1})
  </code></pre>
  
  <p>... I would expect <code>cast</code> to turn that <code>owned_by_id</code> integer param into a string, based on the <code>field</code> declaration.</p>
  
  <p>However, what I get instead is a changeset that includes</p>
  
  <pre><code>errors: [owned_by_id: {"is invalid", [type: :string]}]
  </code></pre>
  
  <p>I could call <code>Integer.to_string(1)</code> myself, but shouldn't <code>cast</code> handle that? Is there a way to have it handle this automatically?</p>