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

namespace BaseDomain.SimpleValidator
{
    public class ValidationRule<T>
    {
        public ValidationRule()
        {
        }

        public ValidationRule(Func<T, bool> validationExpression, Func<T, bool> onlyIf, String errorMessage)
        {
            ValidationExpression = validationExpression;
            OnlyIf = onlyIf;
            ErrorMessage = errorMessage;
        }
        public ValidationRule(Func<T, bool> validationExpression, String errorMessage)
        {
            ValidationExpression = validationExpression;
            ErrorMessage = errorMessage;
        }
        /// <summary>
        /// Validation rule expression, examp. check is string null or empty !string.IsNullOrEmpty(o.Name)
        /// </summary>
        public Func<T, bool> ValidationExpression { get; set; }

        /// <summary>
        /// You can specify OnlyIf expression, if this expresion is specified than ValidationExpression is going to be evaluated only if OnlyIf rule is satisfied
        /// </summary>
        public Func<T, bool> OnlyIf { get; set; }

        /// <summary>
        /// Specify error message that will be returned if rule is not satisifed
        /// </summary>
        public string ErrorMessage { get; set; }
    }
}
