Closed duzzifelipe closed 3 years ago
Hey. I think this problem is specific to ex_machina. I don't think it's a common behavior, see here the alternative to ex_machina: https://hexdocs.pm/ecto/test-factories.html. No changeset is even used.
See here the discussion on that issue: https://github.com/mathieuprog/polymorphic_embed/pull/26
Currently, when you try to normally cast a value into a polymorphic field, not using the specific
cast_polymorphic_embed
function, you receive a raised error.Although, some libraries such as ex_machina casts fields directly without using a changeset. I feel this is a common behavior when you're mocking data, for example.
The idea of this PR is to let users choose if they want to raise on normal cast or just let the value be encoded "as is".