DockYard / valid_field

https://hex.pm/packages/valid_field
MIT License
48 stars 6 forks source link

Fail when field does not exists #30

Open zimt28 opened 6 years ago

zimt28 commented 6 years ago

ValidField should fail, when fields do not exist:

%Resource{}
|> with_changeset()
|> assert_field(:i_dont_exist, [:hi], [])
# Passes

%Resource{}
|> with_changeset()
|> assert_field(:i_dont_exist, [:hi], [:ok])
# ** (ValidField.ValidationError) Expected the following values to be invalid for "nonexistant": :ok

This is helpful when misspelling a field because if no invalid values are set, it might go unnoticed.

bcardarella commented 6 years ago

Good catch, did you want to PR? It might be a bit until I can tackle

zimt28 commented 6 years ago

I tried, see https://github.com/DockYard/valid_field/pull/31.