예제 #1
0
        public bool Validate(T obj)
        {
            TMember member   = MemberSelector.Invoke(obj);
            var     validate = _memberValidation.Invoke(obj, member, ValidatorExpression);

            if (!validate)
            {
                var formattingInfo = _validationExpressionErrorMessageFactory.Invoke(obj);
                ErrorMessageFormat = formattingInfo.Item1;
                FormatObjectArgs   = formattingInfo.Item2;

                FormatObjectArgs.Add(member);

                ErrorMessage = string.Format(ErrorMessageFormat, FormatObjectArgs.ToArray());
            }
            else
            {
                ErrorMessage = string.Empty;
            }

            return(validate);
        }