Ejemplo n.º 1
0
        public static ValidationSpecificationResult Merge(this ValidationSpecificationResult source, ValidationSpecificationResult others)
        {
            if (others.IsNull())
            {
                return(source);
            }

            if (source.IsNotNull())
            {
                source.IsValid = others.Errors.IsAny() ? false : source.IsValid;
                var erros = new List <string>();
                if (source.Errors.IsAny())
                {
                    erros.AddRange(source.Errors);
                }
                if (others.Errors.IsAny())
                {
                    erros.AddRange(others.Errors);
                }
                source.Errors = erros;
                return(source);
            }
            source = others;
            return(source);
        }
Ejemplo n.º 2
0
 public static void ThrowCustomValidationException(this ValidationSpecificationResult result)
 {
     if (result.Errors.IsAny())
     {
         var errors = result.Errors.Distinct().ToList();
         throw new CustomValidationException(errors);
     }
 }