DotVVM Academy

Basic validation

This application is not supported on mobile browsers.

ModelState

Validation occurs before any commands are invoked. You can also create custom validation errors in the command with the AddModelError extension method:

this.AddModelError(vm => vm.ValidatedProperty, "An error.");
Context.FailOnInvalidModelState();

The lambda expression identifies the property that is in an invalid state. The FailOnInvalidModelState call will interrupt the request if there are any errors. These will be displayed to the user.


Tasks

  • Inside the LogIn method:
    • Call accountService.LogIn(Email, Password). This method returns a bool.
    • If the previous call returns false, report a validation error using this.AddModelError.
    • Use vm => vm.Email as the validated property identifier.
MessageLineColumn