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
LogInmethod:- Call
accountService.LogIn(Email, Password). This method returns abool. - If the previous call returns
false, report a validation error usingthis.AddModelError. - Use
vm => vm.Emailas the validated property identifier.
- Call
| Message | Line | Column | |
|---|---|---|---|
|
|