Skip to main content

Built-in Rules and the Validation Extender

The Validation extender replaces the repeated field handlers with reusable Required, Email, Integer, Telephone, Currency and Regex rule arrays. This folder is the complete application at this point in the course, with its own solution and port.

Run it

Requirements: .NET 10 SDK and NuGet access to Wisej-4 4.1.0. Use a Wisej development license or trial as required by your installation. No database setup or external service is needed.

cd "Validation in Wisej.NET Course/Module 3/ValidationClinic"
dotnet run -f net10.0 --urls http://localhost:5903

Open http://localhost:5903. In Visual Studio, open ValidationClinic.slnx and press F5. The project targets both net10.0-windows and net10.0, so the CLI needs -f when running.

What to try

ActionExpected result
Blank email; SaveRequired is first, so the message is Email is required.
Type maria.example.com into email; TabThe Email rule reports the format problem; a valid address clears it.
Use abc for age or X for customer codeInteger and Regex rules reject the values before a write.
Use 2125550123 as phone and 100.50 as credit limitTelephone uses an explicit ten-digit mask; the currency rule accepts a formatted number for the current culture.
Load valid values, choose Fail next write, then SaveA friendly system message appears; the write count does not change. Save again to recover with the same input.
Discard grid editsRestores the last saved snapshot. Working-copy edits are not persisted automatically.

The repository starts with Ada Lovelace and Grace Hopper. Every browser session owns its own repository. Its data disappears when the session ends or the app restarts. The live trace shows which validation stage ran; the write count provides visible evidence that rejected input never called a successful write.

Design notes

Module note records the API choices and failure behavior.

The sample uses AutoValidate.EnableAllowFocusChange: errors remain visible while the user reaches another field to fix a related value. Cancel never causes validation. Save explicitly validates every relevant layer. The in-memory repository is deliberately a storage stand-in; callers own validation, as in the lesson. It checks name uniqueness and swaps the saved snapshot only after all repository checks pass.