Untagged union type argument containing custom types
Howdy :)
I was trying to make an argument for a create action of type :union, which would either be a singleton of some value of a custom type, or an array of values of that custom type.
Snippet of the action:
and the
The idea is the user of this action should be able to pass in either a single tuple e.g (via a code interface)
Under the hood this argument will be converted to be stored as an :array whether it's a single item or not, but I wanted to provide the ability to call the action with a singleton or an array for convenience rather than always needing to pass a list.
I was trying to make an argument for a create action of type :union, which would either be a singleton of some value of a custom type, or an array of values of that custom type.
Snippet of the action:
and the
PetRockRental.Types.Mailbox:The idea is the user of this action should be able to pass in either a single tuple e.g (via a code interface)
PetRockRental.Mail.enqueue_mail(%{to: {"Jane Doe", "jane@example.com"}}) Or a list of tuples PetRockRental.Mail.enqueue_mail(%{to: [{"Jane Doe", "jane@example.com"}, {"John Doe", "john@example.com"}]})Under the hood this argument will be converted to be stored as an :array whether it's a single item or not, but I wanted to provide the ability to call the action with a singleton or an array for convenience rather than always needing to pass a list.

Ash