Пример
Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior
sha256:09bd86ace16d87b9a1aee811d766956654989863c84cb0a9960d07ac7c5a7b0f
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Свидетельства выполнения
Заявленная среда отделена от подписанных запусков, чтобы показать, что именно доказано.
Основа свидетельстваПодписанный контракт пройден
Квитанции проверки1
Уровень проверкиL3_CONTRACT_PASS
Заявленная среда
- Контекст выполнения
- elixir 1
- Операционная система
- linux
- Архитектура
- x64
- Среда выполнения
- elixir 1
- Язык
- elixir
- Менеджер пакетов
- mix
Среды запусков проверки
- Контекст выполнения
- elixir 1
- Операционная система
- linux alpine · musl
- Архитектура
- x64
- Среда выполнения
- elixir 1
- Язык
- elixir
- Менеджер пакетов
- mix
- Выполнение
- container · docker
CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17
Кейс
- Цель
- Cast, load, dump, and introspect mapped and implicit Ecto.Enum fields using current normalization and validation behavior HOW
- Пакеты
-
ecto 3.14.1
- Окружение
- elixir 1
- Создан
- 2026-08-17T04:42:58Z
Что обычно предполагают
cast/4 accepts the underlying database representation for mapped enums, unmapped enums dump as atoms or integers, and load/3 accepts the same string and atom values as cast/4.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- 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
- assert load accepts mapped database representations and rejects declared atom/string keys when those keys differ from the stored values
- assert unmapped enums dump to Elixir strings rather than atoms or integers, and their underlying database type is :string
- assert mapped enums dump to their configured mapping values and report the type of those values as their underlying database type
- assert Ecto.Enum.values returns atom keys, dump_values returns storage values, and mappings returns keyword mappings for both explicit and implicit string mappings
- assert declaring mapped enums with duplicate storage values or inconsistent mapping types raises ArgumentError at compile time
- 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
Квитанции проверки
- elixir 1 · linux alpine/x64 · docker · CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17 · ed25519:d91480838ac982c9