Open zimt28 opened 6 years ago
Hi! First, thanks for this great library – this is the only sane way to test changesets I could find 👍
Currently there is an issue with embedded schemas (using |> cast_embed(:address, required: true)):
|> cast_embed(:address, required: true)
@valid params_for(:address) @invalid params_for(:address, city: nil) # This passes, but shouldn't %Resource{} |> with_changeset() |> assert_field( :address, [@invalid, %{totally_invalid: :yes}], [nil, ""] ) # -> Passes # This doesn't pass, but should %Resource{} |> with_changeset() |> assert_field( :address, [], [nil, "", @invalid, %{invalid: :yes}] ) # ** (ValidField.ValidationError) Expected the following values to be invalid for "address": # %{city: "", country_iso: "DE", postcode: "66960-5408", street: "Aliyah Prairie 7"}, # %{invalid: :yes}
When passing the wrong params for the embedded schema to the changeset manually, it's invalid as expected.
It took me some time to figure it out, but I think I've done it. See https://github.com/DockYard/valid_field/pull/32
Hi! First, thanks for this great library – this is the only sane way to test changesets I could find 👍
Currently there is an issue with embedded schemas (using
|> cast_embed(:address, required: true)
):When passing the wrong params for the embedded schema to the changeset manually, it's invalid as expected.