Skip to content

feat: support {:array, Ash.Type.Atom} with one_of constraints in TypeMapper#6

Merged
mikehostetler merged 1 commit intoagentjido:mainfrom
Munksgaard:feat/array-atom-enum-constraint-v2
Apr 1, 2026
Merged

feat: support {:array, Ash.Type.Atom} with one_of constraints in TypeMapper#6
mikehostetler merged 1 commit intoagentjido:mainfrom
Munksgaard:feat/array-atom-enum-constraint-v2

Conversation

@Munksgaard
Copy link
Copy Markdown
Contributor

Adds a new clause to maybe_add_enum_constraint/2 that handles {:array, Ash.Type.Atom} with nested items: [one_of: [...]] constraints.

Previously, only plain Ash.Type.Atom fields with one_of were converted to {:in, string_values}. Array-of-atom fields like:

field :document_types, {:array, :atom},
  constraints: [items: [one_of: [:individual_policy, :multi_policy, :overview]]]

Would produce {:list, :atom} instead of {:list, {:in, ["individual_policy", "multi_policy", "overview"]}}.

This matters for structured LLM output schemas — without the enum constraint, the JSON schema lacks the allowed values and the model can return arbitrary strings.

@mikehostetler mikehostetler merged commit 9529283 into agentjido:main Apr 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants