Ecto fields validations

You could create a validation layer in your application. Simple field-level validations can be executed client-side also (when using input forms), this saves roundtrips to the server. You don’t want to maintain the same validation in multiple places (f.e. javascript on the client + elixir on the server) so you could use a DSL to generate the same validation in different languages (or you can write DSL interpreters for the languages you use). https://www.cas.mcmaster.ca/~carette/publications/FedorenkoThesis.pdf is interesting on the subject. Maybe examples for validation DSL’s can be found with google.
Previous discussion on this forum: Code.eval_something .
Of course validations can be hard-coded in the db also. That means at least a vendor-lockin. What if you want another kind of db?

1 Like