CodeSampleX

Sample

ecto 3.14.1: Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior

Verified sample for hex ecto 3.14.1: Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation…

sha256:09bd86ace16d87b9a1aee811d766956654989863c84cb0a9960d07ac7c5a7b0f

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment elixir 1 linux x64 elixir 1 elixir mix

Verification-run environments

Environment Contract Stages Run
elixir 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-17
elixir 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-18

Case

HOW
Goal
Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior
Packages
Symbols
  • Ecto.Enum
  • Ecto.Enum.values
  • Ecto.Enum.dump_values
  • Ecto.Enum.mappings
  • Ecto.Type.cast
  • Ecto.Type.load
  • Ecto.Type.dump
  • Ecto.Type.type
  • Ecto.Type.equal?
  • Ecto.Changeset.cast
Environment
elixir 1
Created
2026-08-17T04:42:58Z

Contract

  1. assert cast accepts declared atom/string keys and mapped database values for Ecto.Enum, normalizing them to the declared atom while rejecting values outside both sets
  2. assert load accepts mapped database representations and rejects declared atom/string keys when those keys differ from the stored values
  3. assert unmapped enums dump to Elixir strings rather than atoms or integers, and their underlying database type is :string
  4. assert mapped enums dump to their configured mapping values and report the type of those values as their underlying database type
  5. assert Ecto.Enum.values returns atom keys, dump_values returns storage values, and mappings returns keyword mappings for both explicit and implicit string mappings
  6. assert declaring mapped enums with duplicate storage values or inconsistent mapping types raises ArgumentError at compile time
  7. assert cast stores normalized atoms in changes and reports unknown enum inputs with inclusion metadata without creating atoms dynamically

Files

  • NOTES.md
  • csx.json
  • lib/account.ex
  • mix.exs
  • mix.lock
  • test/contract_test.exs
  • test/test_helper.exs

Download the source artifact (tar.gz)

Origin Seeder

csx-seed