Lavash.Transformers.ValidateBase (Lavash v0.4.0-rc.5)

Copy Markdown View Source

Layer-2 strictness check. Runs only when the module declares itself as layer-2-only (via use Lavash.LiveView.Base or use Lavash.Component.Base) and rejects any use of layer-4 features:

  • state :foo, optimistic: true
  • state :foo, animated: ...
  • calculate :foo, rx(...), optimistic: true

The schema still accepts these keys (they live in Lavash.Optimistic.SchemaExtension and are appended to the base schemas in Lavash.Dsl.CommonEntities). This transformer catches them after parse time and turns them into a friendly compile-time error explaining the layering choice.

Why a transformer rather than removing the keys from the schema: swapping the schema would require parameterizing base_state_schema/0 per-extension. The transformer approach produces better error messages and keeps the schema definition in one place.

Summary

Functions

after?(arg1)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl_state)

Callback implementation for Spark.Dsl.Transformer.transform/1.