1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-27 22:57:09 -04:00
Files
Radarr/src/NzbDrone.Core/Validation/FolderValidator.cs
T
Bogdan 933c23ce57 New: Improve validation messages
(cherry picked from commit a117001de673e80abd90d54a34a7c86292b3a649)
2023-05-22 01:14:49 +03:00

24 lines
685 B
C#

using FluentValidation.Validators;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Validation
{
public class FolderValidator : PropertyValidator
{
protected override string GetDefaultMessageTemplate() => "Invalid Path: '{path}'";
protected override bool IsValid(PropertyValidatorContext context)
{
if (context.PropertyValue == null)
{
return false;
}
context.MessageFormatter.AppendArgument("path", context.PropertyValue.ToString());
return context.PropertyValue.ToString().IsPathValid(PathValidationType.CurrentOs);
}
}
}