예제 #1
0
        public static ValidationMappingExpression <TSource, TDestination> CreateMap <TSource, TDestination>()
        {
            var expression = new ValidationMappingExpression <TSource, TDestination>();

            Expressions.Add(expression);
            return(expression);
        }
예제 #2
0
        public static IEnumerable <IValidationError> Map <TSource, TDestination>(IEnumerable <IValidationError> errors)
        {
            ValidationMappingExpression vme = GetExpression <TSource, TDestination>();

            foreach (var error in errors)
            {
                string mappedPath = vme.MapPath(error.PropertyPath);
                if (!string.IsNullOrWhiteSpace(mappedPath))
                {
                    yield return(new MappedValidationError(error)
                    {
                        PropertyPath = mappedPath,
                        Message = vme.MapMessage(error.PropertyPath, error.Message)
                    });
                }
            }
        }