ASP.NET validation
When doing HTTP requests against ASP.NET, it goes through a pipeline consisting of different middlewares with specific responsibilities. This pipeline is completely configurable and extensible by you as a developer. Out of the box, it comes pre-configured with a specific middleware that handles the validation of objects sent to a request. The validation engine behind this recognizes rules in the form of metadata that can be applied to the objects. This metadata again is based on C# attributes.
Let’s start by changing our Employee object a bit. Open the Employee.cs file and make it look like the following:
public record Employee( [Required] string FirstName, [Required] string LastName);
This makes the FirstName and LastName properties required by adding the [Required] attribute to them. The ASP.NET pipeline will pick this up and check any input being sent...