Category: elixir

  • Ecto Custom Validation Elixir Phoenix

    We often need to validate fields that are passed through a struct in Ecto Changesets. Custom validations are very straightforward to write and can be composed with one another easily. By using validate_change/3 which invokes a validator function, the function returns either a) the changeset or b) the changeset with errors if the validation fails.