aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-05-16 19:01:50 -0500
committerJP Dillingham <jp@dillingham.me>2026-05-16 19:01:50 -0500
commit0346199c4ed5edb0d502f2e3f5972aafeea6c923 (patch)
treea53c7ffb35006f074695e8a2767935c5d755e633 /src
parentaee67635e0c1048b890bc98812678086407d3b92 (diff)
downloadslskd-0346199c4ed5edb0d502f2e3f5972aafeea6c923.tar.gz
fix test
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/Validation/StringAttribute.cs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/slskd/Common/Validation/StringAttribute.cs b/src/slskd/Common/Validation/StringAttribute.cs
index 2fcf4283..bb323ba2 100644
--- a/src/slskd/Common/Validation/StringAttribute.cs
+++ b/src/slskd/Common/Validation/StringAttribute.cs
@@ -53,9 +53,16 @@ namespace slskd.Validation
{
var val = (string)value;
- if (!AllowNull && val is null)
+ if (val is null)
{
- return new ValidationResult($"The {validationContext.DisplayName} field must not be null");
+ if (!AllowNull)
+ {
+ return new ValidationResult($"The {validationContext.DisplayName} field must not be null");
+ }
+ else
+ {
+ return ValidationResult.Success;
+ }
}
if (!AllowEmpty && val is "")
@@ -64,7 +71,7 @@ namespace slskd.Validation
}
// check this after empty to avoid overlap
- if (!AllowWhiteSpace && string.IsNullOrWhiteSpace(val))
+ if (!AllowWhiteSpace && val.All(c => char.IsWhiteSpace(c)))
{
return new ValidationResult($"The {validationContext.DisplayName} field must not contain only whitespace");
}