static bool ShouldThrowForError(ResolvedValidationOptions options)
 => new[] { RuleThrowingBehaviour.OnError, RuleThrowingBehaviour.OnFailure }.Contains(options.RuleThrowingBehaviour);
 static bool ShouldThrowForFailure(ResolvedValidationOptions options)
 => options.RuleThrowingBehaviour == RuleThrowingBehaviour.OnFailure;
        static void ThrowForUnsuccessfulValidationIfApplicable(IQueryableValidationResult result, ResolvedValidationOptions options)
        {
            if (ShouldThrowForError(options) && result.RuleResults.Any(x => x.Outcome == Rules.RuleOutcome.Errored))
            {
                var message = String.Format(Resources.ExceptionMessages.GetExceptionMessage("ErrorInValidation"),
                                            nameof(ResolvedValidationOptions),
                                            nameof(ResolvedValidationOptions.RuleThrowingBehaviour),
                                            nameof(RuleThrowingBehaviour),
                                            options.RuleThrowingBehaviour,
                                            nameof(ValidationResult),
                                            nameof(RuleOutcome.Errored));
                throw new ValidationException(message, (ValidationResult)result);
            }

            if (ShouldThrowForFailure(options) && result.RuleResults.Any(x => x.Outcome == Rules.RuleOutcome.Failed))
            {
                var message = String.Format(Resources.ExceptionMessages.GetExceptionMessage("FailureInValidation"),
                                            nameof(ResolvedValidationOptions),
                                            nameof(ResolvedValidationOptions.RuleThrowingBehaviour),
                                            nameof(RuleThrowingBehaviour),
                                            options.RuleThrowingBehaviour,
                                            nameof(ValidationResult),
                                            nameof(RuleOutcome.Errored),
                                            nameof(RuleOutcome.Failed));
                throw new ValidationException(message, (ValidationResult)result);
            }
        }