27 lines
598 B
C#
27 lines
598 B
C#
// See https://aka.ms/new-console-template for more information
|
|
|
|
using FluentValidation.Results;
|
|
|
|
Console.WriteLine("Hello, World!");
|
|
|
|
var customer = new Customer();
|
|
var validator = new CustomerValidator();
|
|
|
|
// Execute the validator.
|
|
var results = validator.Validate(customer);
|
|
|
|
// Inspect any validation failures.
|
|
var success = results.IsValid;
|
|
|
|
if (!success)
|
|
{
|
|
Console.WriteLine("Validation failed");
|
|
foreach (var failure in results.Errors)
|
|
{
|
|
Console.WriteLine(failure.ErrorMessage);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Validation succeeded");
|
|
} |