You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
664 B
24 lines
664 B
using System.Linq;
|
|
using FluentValidation;
|
|
|
|
namespace NzbDrone.Core.Validation
|
|
{
|
|
public static class NzbDroneValidationExtensions
|
|
{
|
|
public static NzbDroneValidationResult Filter(this NzbDroneValidationResult result, params string[] fields)
|
|
{
|
|
var failures = result.Failures.Where(v => fields.Contains(v.PropertyName)).ToArray();
|
|
|
|
return new NzbDroneValidationResult(failures);
|
|
}
|
|
|
|
public static void ThrowOnError(this NzbDroneValidationResult result)
|
|
{
|
|
if (!result.IsValid)
|
|
{
|
|
throw new ValidationException(result.Errors);
|
|
}
|
|
}
|
|
}
|
|
}
|