Capturing errors
You’ll remember that our Car
object (defined in Chapter 3) looks like this:
public class Car { public int id { get; set; } public string name { get; set; } public string mpg { get; set; } public string cylinders { get; set; } public string displacement { get; set; } public string horsepower { get; set; } public string weight { get; set; } public string acceleration { get; set; } public string model_year { get; set; } public string origin { get; set; } public string? is_deleted { get; set;} }
Let’s also say that cars must not be deleted. You can create a validator for that pretty quickly. First, add a Using
statement:
Using FluentValidation
Next, create a class that derives from AbstractValidator...