Virtual Fields With Ecto Schemas
schema "users" do
field :username, :string
field :password_digest, :string
field :password, :string, virtual: true
enddef registration_changeset(model, params) do
model
|> changeset(params) # do other standard validations
|> cast(params, [:password]) # include :password in the changeset
|> validate_length(:password, min: 8) # validations
|> put_pass_hash() # transform into :password_digest
endLast updated