Ecto.Changeset.cast/4

Parsed documentation:
View on GitHub
Converts the given `params` into a changeset for `model`
keeping only the set of `required` and `optional` keys.

This functions receives the `params` and cast them according
to the schema information from `model`. `params` is a map of
string keys or a map with atom keys containing potentially
unsafe data.

During casting, all valid parameters will have their key name
converted to atoms and stored as a change in the changeset.
All other parameters that are not listed in `required` or
`optional` are ignored.

If casting of all fields is successful and all required fields
are present either in the model or in the given params, the
changeset is returned as valid.

## No parameters

The `params` argument can also be nil. In such cases, the
changeset is automatically marked as invalid, with an empty
changes map. This is useful to run the changeset through
all validation steps for introspection.

## Examples

    iex> changeset = cast(params, post, ~w(title), ~w())
    iex> if changeset.valid? do
    ...>   Repo.update(changeset)
    ...> end
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.