Пример #1
0
        static void Main(string[] args)
        {
            // OBJECT TO VALIDATE
            Address a = new Address()
            {
                Id = 1
            };
            Customer c = new Customer()
            {
                FirstName = "Samwiser",
                LastName = string.Empty,
                BillingAddress = a,
            };

            Validate(c);

            Console.ReadKey();
        }
Пример #2
0
        private static void Validate(Customer customer)
        {
            // CALL VALIDATION
            var results = new List<ValidationResult>();
            if (AppendValidation(customer, results))
            {
                Console.WriteLine("Validation succeeded.");
            }
            else
            {
                Console.WriteLine("Error during validation:");
            }

            // PRINT RESULTS
            if (results.Any())
            {
                results.ForEach(Console.WriteLine);
            }
        }