A2UI.DataModel.Functions (A2UI v0.3.0)

Copy Markdown View Source

Evaluates A2UI client-side function descriptors server-side.

Handles formatting functions (formatString, formatNumber, formatCurrency, formatDate, pluralize) and boolean logic functions (and, or, not).

Unknown functions (e.g., openUrl, validators) pass through as raw descriptors.

Summary

Functions

Evaluates a named function with the given args against a data model.

Functions

evaluate(name, args, data_model, scope_path)

@spec evaluate(String.t(), map(), A2UI.DataModel.t(), String.t() | nil) ::
  {:ok, any()} | :pass_through

Evaluates a named function with the given args against a data model.

Returns {:ok, result} for known functions or :pass_through for unknown ones. If any required arg fails to resolve, returns :pass_through.

Parameters

  • name — function name (e.g., "formatNumber")
  • args — map of argument names to values (may contain path bindings)
  • data_model — the %DataModel{} for resolving path bindings in args
  • scope_path — base path for relative path resolution