Zongzi. Util. Model behaviour
(zongzi v0.3.0)
Copy Markdown
Domain model helper.
by invoke use Zongzi.Util.Model, keys: [...], id_prefix: "xxx" will generate automatically:
- struct defination
new/1— Have to provide:idexplicitly (a pure function, not automatically generated).validate/1update/2
ID Generation
new/1 no longer generates an ID automatically. The caller generates the ID using Zongzi.Util.ID.generate_id/1 and passes it in.
It ensures the Domain layer does not rely on random numbers.
Writing business functions (recommended)
Return {:ok, result} or {:error, reason} .
Summary
Callbacks
Check if the domain model is valid.