CodeSampleX

サンプル

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

検証済みサンプル — hex ecto 3.14.1: Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior. elixir…

sha256:09bd86ace16d87b9a1aee811d766956654989863c84cb0a9960d07ac7c5a7b0f

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 elixir 1 linux x64 elixir 1 elixir mix

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior
パッケージ
シンボル
  • 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
環境
elixir 1
作成日
2026-08-17T04:42:58Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed