コード例 #1
0
        public static string?ErrorMessageOf(this IEnumerable <ValidationResult> validationResults, string propertyName)
        {
            ThrowIf.Null(validationResults, nameof(validationResults));
            ThrowIf.NullOrEmpty(propertyName, nameof(propertyName));

            foreach (ValidationResult result in validationResults)
            {
                if (result.MemberNames.Contains(propertyName))
                {
                    return(result.ErrorMessage);
                }
            }

            return(null);
        }
コード例 #2
0
        public static bool ExistErrorOf(this IEnumerable <ValidationResult> valiationResults, string propertyName)
        {
            ThrowIf.Null(valiationResults, nameof(valiationResults));
            ThrowIf.NullOrEmpty(propertyName, nameof(propertyName));

            foreach (ValidationResult result in valiationResults)
            {
                if (result.MemberNames.Contains(propertyName))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        public static bool ExistError(this IEnumerable <ValidationResult> valiationResults)
        {
            ThrowIf.Null(valiationResults, nameof(valiationResults));

            return(valiationResults.Any());
        }