ecto-changeset-patterns
Installation
SKILL.md
Ecto Changeset Patterns
RULES — Quick Checklist
- Separate named changesets per operation (
registration_changeset,email_changeset, etc.) - Never require foreign key fields in
cast_assocchild changesets - Compose changesets with pipes; each validation step is a separate function
- Always pair
unsafe_validate_uniquewithunique_constraint - Use
update_change/3for field transformations (trim, downcase, slugify) - Accept
opts \\ []for conditional validation - Validate at the changeset level, not in context functions
Workflow: Building a New Schema
When adding changesets to a new schema, apply patterns in this order: