4 ms·
One note when using this for form validation. If you have a multi-column unique index Phoenix will show the error for the field defined first in the constraint
by dugmartin 4y ago
One note when using this for form validation. If you have a multi-column unique index Phoenix will show the error for the field defined first in the constraint in the schema definition. This has tripped me up a couple of times for user input where the constraint is something like tag+post_id. If your form just has the tag input and you put post_id as the first item in the constraint the changeset will be invalid but no error will show.
- porker 4y agoThat... sounds like a good candidate for a bug report/feature request.
- sb8244 4y agoYea this has gotten me too. What I do now is specify the field I want the error on first in the constraint function, then manually set the index name. It will still work exactly as expected if you provide the index name manually, even if it's not the same order as the constraint in the DB.