Get required_fields from changeset

No. But you can filter the values in Model.__ schema__(:fields)

Or you can write your own functions or macros to return these fields

def required_fields do
  @required_fields
end

Then the filter would work like this

required_fields = Model.required_fields()
Model.__ schema__(:fields)
|> Enum.filter(fn field -> field in required_fields end)

EDIT: ignore me, see the answer below.

2 Likes