using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Project1Demo.Core.CrossCuttingConcerns.Validation.FluentValidation
{
    public class ValidatorTool
    {
        public static void FluentValidate(IValidator validator,object entity) 
        {

            var context = new ValidationContext<object>(entity);
            var result = validator.Validate(context);

            if (result.Errors.Count>0) 
            {
                throw new ValidationException(result.Errors);
            }
        }
    }
}
