View Source Jido.Util (Jido v1.0.0-rc.1)
A collection of utility functions for the Jido framework.
This module provides various helper functions that are used throughout the Jido framework, including:
- ID generation
- Name validation
- Error handling
- Logging utilities
These utilities are designed to support common operations and maintain consistency across the Jido ecosystem. They encapsulate frequently used patterns and provide a centralized location for shared functionality.
Many of the functions in this module are used internally by other Jido modules, but they can also be useful for developers building applications with Jido.
Summary
Functions
@spec generate_id() :: String.t()
Generates a unique ID.
@spec validate_name(any()) :: {:ok, String.t()} | {:error, Jido.Error.t()}
Validates the name of a Action.
The name must contain only letters, numbers, and underscores.
Parameters
name
: The name to validate.
Returns
{:ok, name}
if the name is valid.{:error, reason}
if the name is invalid.
Examples
iex> Jido.Action.validate_name("valid_name_123")
{:ok, "valid_name_123"}
iex> Jido.Action.validate_name("invalid-name")
{:error, %Jido.Error{type: :validation_error, message: "The name must contain only letters, numbers, and underscores."}}