Unified value formatting for RPC input/output.
Traverses composite values recursively, applying field name mappings and type-aware formatting at each level.
The type and constraints parameters provide all context needed - no separate "resource" context is required because each type is self-describing:
- For Ash resources: field types come from
Ash.Resource.Info.attribute/2 - For TypedStructs: field types come from
constraints[:fields] - For typed maps: field types come from
constraints[:fields] - For unions: member type and constraints come from
constraints[:types][member]
Key Design Principle
The "parent resource" is never needed because each type is self-describing. When we recurse into a nested value, we pass the field's type and constraints, which contain all the information needed to format that value correctly.
Summary
Functions
Formats a value based on its type and constraints.
Types
Functions
Formats a value based on its type and constraints.
Parameters
value- The value to formattype- The Ash type (e.g.,MyApp.EmbeddedResource,Ash.Type.Map,{:array, X})constraints- Type constraints (e.g.,[fields: [...]],[instance_of: Module])formatter- The field formatter configuration (:camel_case,:snake_case, etc.)direction-:input(client→internal) or:output(internal→client)
Returns
The formatted value with field names converted according to direction.