Dala.Spark.DslVerifier (dala v0.10.0)

Copy Markdown View Source

Comprehensive DSL verification for Dala screen modules.

Validates user-defined screens against the component registry and reports warnings/errors for:

  • Unknown component types
  • Invalid prop names
  • Missing required props
  • Event handler props that are not atoms
  • Invalid attribute types
  • Missing handle_event/3 for declared event handlers
  • Children placed inside leaf components
  • Invalid variant values
  • Deprecated prop usage

Summary

Functions

Suggest the closest valid prop for a mistyped key, or nil when nothing is close enough. Shared by the runtime verifier and the DSL's parse-time prop validation.

Event names handled by handle_event/3 clauses in module.

Format a list of warnings into a human-readable report.

Missing / unused handle_event warnings for a compiled module.

Print warnings to the Mix shell with appropriate coloring.

Verify DSL from raw entity/attribute/handler data (used by compile-time hook).

Verify a single screen module's DSL definition.

Types

warning()

@type warning() :: %{
  type: :error | :warning | :info,
  module: atom(),
  line: non_neg_integer(),
  message: String.t()
}

Functions

closest_match(key, valid_props)

@spec closest_match(atom(), [atom()]) :: atom() | nil

Suggest the closest valid prop for a mistyped key, or nil when nothing is close enough. Shared by the runtime verifier and the DSL's parse-time prop validation.

defined_handlers(module)

@spec defined_handlers(module()) :: [atom()]

Event names handled by handle_event/3 clauses in module.

Reads the module's compiled debug_info, so it works for fully-compiled modules (runtime verification, mix dala.verify). Returns [] when the beam or debug info is unavailable — e.g. from inside the compile hook, where only missing-handler checks are possible.

format_report(warnings)

@spec format_report([warning()]) :: String.t()

Format a list of warnings into a human-readable report.

handler_warnings(module)

@spec handler_warnings(module()) :: [warning()]

Missing / unused handle_event warnings for a compiled module.

Used by the @after_verify hook so a typo'd on_tap surfaces during mix compile instead of as a runtime crash or a manual mix dala.verify. Returns [] when the module or its beam is unavailable.

verify_from_raw(module, entities, attributes, handlers)

@spec verify_from_raw(module(), [map()], [map()], [map()]) :: [warning()]

Verify DSL from raw entity/attribute/handler data (used by compile-time hook).

verify_module(module)

@spec verify_module(module()) :: [warning()]

Verify a single screen module's DSL definition.

Returns a list of warnings/errors found.