Runtime introspection for the GuardedStruct.AshResource extension.
Same shape as GuardedStruct.Info but reads from the __guarded_*
namespaced functions the Ash extension generates (so it doesn't
collide with Ash's own Ash.Resource.Info callbacks).
Example
defmodule MyApp.User do
use Ash.Resource,
domain: MyApp.MyDomain,
extensions: [GuardedStruct.AshResource]
guardedstruct do
field :nickname, :string, derives: "validate(string, max_len=20)"
end
end
GuardedStruct.AshResource.Info.fields(MyApp.User)
#=> [:nickname]
GuardedStruct.AshResource.Info.field(MyApp.User, :nickname)
#=> %{kind: :field, name: :nickname, derives: "validate(string, max_len=20)", ...}
Summary
Functions
Return metadata for a single field name, or nil.
True if a guardedstruct-declared field exists with this name.
Return field, sub_field, and conditional_field names in declaration order.
Return the runtime field metadata stored under __guarded_fields__/0.
guardedstruct DSL entities
Only effective inside the GuardedStruct.AshResource extension. When true, injects GuardedStruct.AshResource.Change into the resource's top-level changes section so every :create and :update action automatically runs the GuardedStruct pipeline. Equivalent to writing changes do change GuardedStruct.AshResource.Change end by hand. No-op outside the Ash extension.
Only effective inside the GuardedStruct.AshResource extension. When true, injects GuardedStruct.AshResource.Change into the resource's top-level changes section so every :create and :update action automatically runs the GuardedStruct pipeline. Equivalent to writing changes do change GuardedStruct.AshResource.Change end by hand. No-op outside the Ash extension.
When true, derives a JSON encoder. Uses Jason.Encoder if :jason is in the user's deps; otherwise falls back to the built-in JSON.Encoder on Elixir 1.18+. No-op if neither is available.
When true, derives a JSON encoder. Uses Jason.Encoder if :jason is in the user's deps; otherwise falls back to the built-in JSON.Encoder on Elixir 1.18+. No-op if neither is available.
guardedstruct DSL options
Return the full information map (path, keys, enforce_keys, options, etc.).
Run the validation pipeline on attrs and return {:ok, validated_map}
or {:error, errors}. Convenience wrapper over the resource's own
__guarded_change__/1.
Functions
Return metadata for a single field name, or nil.
True if a guardedstruct-declared field exists with this name.
Return field, sub_field, and conditional_field names in declaration order.
Return the runtime field metadata stored under __guarded_fields__/0.
guardedstruct DSL entities
Only effective inside the GuardedStruct.AshResource extension. When true, injects GuardedStruct.AshResource.Change into the resource's top-level changes section so every :create and :update action automatically runs the GuardedStruct pipeline. Equivalent to writing changes do change GuardedStruct.AshResource.Change end by hand. No-op outside the Ash extension.
Only effective inside the GuardedStruct.AshResource extension. When true, injects GuardedStruct.AshResource.Change into the resource's top-level changes section so every :create and :update action automatically runs the GuardedStruct pipeline. Equivalent to writing changes do change GuardedStruct.AshResource.Change end by hand. No-op outside the Ash extension.
When true, derives a JSON encoder. Uses Jason.Encoder if :jason is in the user's deps; otherwise falls back to the built-in JSON.Encoder on Elixir 1.18+. No-op if neither is available.
When true, derives a JSON encoder. Uses Jason.Encoder if :jason is in the user's deps; otherwise falls back to the built-in JSON.Encoder on Elixir 1.18+. No-op if neither is available.
guardedstruct DSL options
Returns a map containing the and any configured or default values.
Return the full information map (path, keys, enforce_keys, options, etc.).
Run the validation pipeline on attrs and return {:ok, validated_map}
or {:error, errors}. Convenience wrapper over the resource's own
__guarded_change__/1.