Skip to content

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

  1. Call the derived ValidateData() (BR-MVC-029).
  2. Only when validation returns True, call the derived WriteData() and return its result.
  3. If validation returns False: return False immediately without calling WriteData() — no write is attempted.
  4. clsControllerBase.Write simply 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 True from ValidateData effectively 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).

Sources

  • SAIF.Presentation.Web.MVC/clsModelBase.vb
  • SAIF.Presentation.Web.MVC/clsControllerBase.vb