From 8b5505ba5e1c102cd639666df96e139a5858ed55 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 21 May 2026 23:10:22 -0500 Subject: add overload allowing OS selection --- src/slskd/Common/Validation/RelativePathAttribute.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/slskd/Common/Validation/RelativePathAttribute.cs') diff --git a/src/slskd/Common/Validation/RelativePathAttribute.cs b/src/slskd/Common/Validation/RelativePathAttribute.cs index 64e418b1..f465ba98 100644 --- a/src/slskd/Common/Validation/RelativePathAttribute.cs +++ b/src/slskd/Common/Validation/RelativePathAttribute.cs @@ -33,19 +33,30 @@ namespace slskd.Validation { using System.ComponentModel.DataAnnotations; + using System.Runtime.InteropServices; /// /// Validates that the specified path is relative. /// public class RelativePathAttribute : ValidationAttribute { + public RelativePathAttribute() + { + } + + public RelativePathAttribute(OSPlatform? os = null) + { + OS = os; + } + + public OSPlatform? OS { get; } protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null && value is string str && !string.IsNullOrEmpty(str)) { var path = value.ToString(); - if (!FileSafety.IsPathRelative(path)) + if (!FileSafety.IsPathRelative(path, os: OS)) { return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); } -- cgit v1.2.3