BB.Parameter.Type (bb v0.15.0)

View Source

Validation for parameter type definitions in the DSL.

Parameters can have simple types (:float, :integer, etc.) or unit types like {:unit, :meter}.

Summary

Functions

Validates a parameter type specification.

Functions

validate(type)

@spec validate(term()) :: {:ok, atom() | {:unit, atom()}} | {:error, String.t()}

Validates a parameter type specification.

Returns {:ok, type} for valid types or {:error, message} for invalid ones.

Valid Types

  • Simple types: :float, :integer, :boolean, :string, :atom
  • Unit types: {:unit, unit_type} where unit_type is a valid CLDR unit

Examples

iex> BB.Parameter.Type.validate(:float)
{:ok, :float}

iex> BB.Parameter.Type.validate({:unit, :meter})
{:ok, {:unit, :meter}}

iex> BB.Parameter.Type.validate(:invalid)
{:error, "Expected one of [:float, :integer, :boolean, :string, :atom] or {:unit, unit_type}, got: :invalid"}