using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.EnterpriseLibrary.Validation;

namespace ValidationInCode
{
    class Program
    {
        static void Main(string[] args)
        {
            var validator = ValidationFactory.CreateValidator<Zamowienie>();

            var zamowienie = new Zamowienie
            {
                Numer = "abc",
                Odbiorca = "John Kowalski",
                AdresDostawy = string.Empty,
                DataZlozenia = DateTime.Now.AddDays(-2),
                DataWyslania = DateTime.Now.AddDays(-3),
                DataDostarczenia = DateTime.Now.AddDays(2)
            };

            var results = validator.Validate(zamowienie);

            if (!results.IsValid)
                foreach (var v in results)
                    Console.WriteLine(v.Message);
        }
    }
}
