Ecto - Postgresql wiki: Don't do this

Right, that’s something I always think to myself when I develop a “for real” public site.

I’ll attach a maxlength to the input box, followed by a max (and potentially min) length with a changeset validation, followed by enforcing a text + constraint at the database level and finish it up with a test to ensure the changeset validates the length. Without all 4 (first one is mainly a UI hint) I feel really uneasy, but at the same time, it’s quite a bit of duplication and remembering to keep things in sync if one of those lengths change later.

1 Like