Required field validation

We will start with the Required built-in validation which allows validators to check whether the field has a value or not. The required validation is necessary to ensure that the mandatory fields are filled in or updated by the user before transmitting the data to the server for further processing.

The following steps will help us in understanding how validation works:

  1. The  Required field validator is added using data annotation in the model.

  2. The MVC engine performs validation on both client-side and server-side using this configuration.
  3. When MVC engine generates the form view with the input field, it also scaffolds the <span> element along with each input field to hold error messages.

  4. When we run the application ...

Get Mastering Entity Framework Core 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.