Validate and write the model¶
The single choke point through which every controller-initiated save passes: the model is never written unless the derived screen's own validation logic confirms the data is valid.
| Field | Value |
|---|---|
| Operation ID | OP-MVC-13 |
| Trigger | clsControllerBase.Write, typically from a Save button handler |
| Inputs | Current model state |
| Outputs | Boolean success; model persisted only when validation passes |
| Primary components | clsModelBase.Write |
| Entry point | SAIF.Presentation.Web.MVC/clsModelBase.vb |
Steps¶
- Call the derived
ValidateData()(BR-MVC-029). - Only when validation returns
True, call the derivedWriteData()and return its result. - If validation returns
False: returnFalseimmediately without callingWriteData()— no write is attempted. clsControllerBase.Writesimply delegates to this operation, so every controller-initiated save passes through the same validation gate.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([clsModelBase.Write]) --> S1[Call derived ValidateData]
S1 --> D1{Validation returned True?}
D1 -->|No| EndFail([Return False - no write attempted])
D1 -->|Yes| S2[Call derived WriteData]
S2 --> EndOk([Return WriteData result])
Failure and edge-case behavior¶
- A screen that always returns
TruefromValidateDataeffectively disables this safeguard — the base class enforces the ordering, not the validation content itself. WriteData's own exceptions are not caught here; they propagate to the caller (typically surfacing through Page error processing).
Related documentation¶
Sources¶
- SAIF.Presentation.Web.MVC/clsModelBase.vb
- SAIF.Presentation.Web.MVC/clsControllerBase.vb