Skip to content

Instantly share code, notes, and snippets.

@AndrewDryga
Created August 19, 2017 14:03
Show Gist options
  • Save AndrewDryga/acd4f79446cd402c11fbfe094fab735b to your computer and use it in GitHub Desktop.
Save AndrewDryga/acd4f79446cd402c11fbfe094fab735b to your computer and use it in GitHub Desktop.
on_load Module callback example (before)
defmodule MyAppAPI.Changeset do
import Ecto.Changeset
@known_buckets Application.get_env(:myapp_api, :known_buckets)
# ...
def changeset(schema, attrs) do
schema
|> cast(attrs, @fields)
|> validate_inclusion(:bucket, @known_buckets)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment