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

namespace ValidationInConfiguration
{
    class Program
    {
        static void Main(string[] args)
        {
            ValidationFactory.SetDefaultConfigurationValidatorFactory(new SystemConfigurationSource());
            var validator = ValidationFactory.CreateValidator<Kandydat>();
            //var validator = ValidationFactory.CreateValidator<Kandydat>("light");

            var kandydat = new Kandydat
            {
                Nazwisko = null,
                Wiek = 15,
                EMail = "ala ma kota"
            };

            //var results = Validation.Validate<Kandydat>(kandydat, "light");
            var results = validator.Validate(kandydat);

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