AshPrefixedId.AnyPrefixedId (ash_prefixed_id v0.2.0)

View Source

A universal PrefixedId type that accepts any prefixed ID.

This type is useful as a global replacement for :uuid when you want all UUID fields (including action arguments, non-AshPrefixedId resources, and manual attributes) to accept prefixed IDs.

Usage

Register as a custom type in your Ash config:

config :ash,
  custom_types: [uuid: AshPrefixedId.AnyPrefixedId]

This replaces the standard Ash.Type.UUID for all :uuid references, making them accept both prefixed IDs ("user_CWzLBdFy2f1XhrtesFferY") and raw UUIDs ("550e8400-e29b-41d4-a716-446655440000").

Behavior

  • Input: Accepts any prefixed ID or raw UUID string
  • Storage: Native PostgreSQL UUID binary (16 bytes)
  • Output: Returns the original prefixed form if available, otherwise the raw UUID string from the database

Summary

Functions

handle_change?()

prepare_change?()