Ash.Changeset.new

You're seeing just the function new, go back to Ash.Changeset module for more information.
Link to this function

new(resource, params \\ %{})

View Source

Specs

new(Ash.Resource.t() | Ash.Resource.record(), params :: map()) :: t()

Return a changeset over a resource or a record. params can be either attributes, relationship values or arguments.

If you are using external input, you almost certainly want to use Ash.Changeset.for_<action_type>. However, you can use Ash.Changeset.new/2 to start a changeset and make a few changes prior to calling for_action. For example:

Ash.Changeset.new()
|> Ash.Changeset.change_attribute(:name, "foobar")
|> Ash.Changeset.for_action(...)

Anything that is modified prior to for_action is validated against the rules of the action, while anything after it is not.

This changeset does not consider an action, and so allows you to change things with minimal validation. Values are validated when changed, and the existence of attributes and relationships are validated. If you want to essentially "run an action", and get back a changeset with any errors that would be generated by that action (with the exception of errors that can only be generated by the data layer), use for_action/4.

Additionally, this format only supports supplying attributes in the params. This is because we don't know what the behavior should be for relationship changes, nor what arguments are available. You can manage them yourself with the functions that allow managing arguments/relationships that are provided in this module, e.g set_argument/3 and replace_relationship/3