View Source GptAgent.Value (gpt_agent v3.1.0)

A module that provides a macro to define a new type and its validation.

Summary

Functions

Macro to use GptAgent.Value in the current module.

Macro to define a new type.

Macro to define a validation function for the type.

Functions

Link to this macro

__using__(opts)

View Source (macro)

Macro to use GptAgent.Value in the current module.

Examples

defmodule MyModule do
  use GptAgent.Value
end
@spec type(atom()) :: Macro.t()

Macro to define a new type.

Examples

defmodule MyType do
  use GptAgent.Value
  type String.t()
end
Link to this macro

validate_with(validate_with)

View Source (macro)
@spec validate_with(Macro.t()) :: Macro.t()

Macro to define a validation function for the type.

Examples

defmodule MyType do
  use GptAgent.Value
  type String.t()
  validate_with fn
    value when is_binary(value) ->
      case String.trim(value) do
        "" -> {:error, "must be a nonblank string"}
        _ -> :ok
      end
  end
end