view models

This commit is contained in:
2025-12-18 13:48:35 +01:00
parent cc2553876a
commit 91adbb9c83
71 changed files with 3119 additions and 359 deletions

View File

@@ -1,10 +1,10 @@
Form Models
Command Models
This document defines Form Models as a first-class concept in the frontend architecture.
Form Models are UX-only write models used to collect, validate, and prepare user input
This document defines Command Models as a first-class concept in the frontend architecture.
Command Models are UX-only write models used to collect, validate, and prepare user input
before it is sent to the backend as a Command DTO.
Form Models are not View Models and not Domain Models.
Command Models are not View Models and not Domain Models.
@@ -14,7 +14,7 @@ A Form Model answers the question:
“What does the UI need in order to safely submit user input?”
Form Models exist to:
Command Models exist to:
• centralize form state
• reduce logic inside components
• provide consistent client-side validation
@@ -24,13 +24,13 @@ Form Models exist to:
Core Rules
Form Models:
Command Models:
• exist only in the frontend
• are write-only (never reused for reads)
• are created per form
• are discarded after submission
Form Models MUST NOT:
Command Models MUST NOT:
• contain business logic
• enforce domain rules
• reference View Models
@@ -46,7 +46,7 @@ API DTO (read) → ViewModel → UI
UI Input → FormModel → Command DTO → API
• View Models are read-only
Form Models are write-only
Command Models are write-only
• No model is reused across read/write boundaries
@@ -137,20 +137,20 @@ The component:
Testing
Form Models SHOULD be tested when they contain:
Command Models SHOULD be tested when they contain:
• validation rules
• non-trivial state transitions
• command construction logic
Form Models do NOT need tests if they only hold fields without logic.
Command Models do NOT need tests if they only hold fields without logic.
Summary
Form Models are UX helpers for writes
Command Models are UX helpers for writes
• They protect components from complexity
• They never replace backend validation
• They never leak into read flows
Form Models help users.
Command Models help users.
Use Cases protect the system.