Skip to content

Commit

Permalink
Fix incorrent validation condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Splamy committed Mar 30, 2024
1 parent 9c523d6 commit 96c0dd1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/BaGetter.Core/Configuration/MirrorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
[nameof(Authentication.Password)]);
}
break;

case MirrorAuthenticationType.Bearer:
if (string.IsNullOrEmpty(Authentication.Token))
{
Expand All @@ -78,12 +79,22 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
[nameof(Authentication.Token)]);
}
break;

case MirrorAuthenticationType.Custom:
if (Authentication.CustomHeaders?.Count == 0)
if (Authentication.CustomHeaders == null)
{
yield return new ValidationResult(
$"The {nameof(Authentication.CustomHeaders)} configuration is required for custom authentication",
[nameof(Authentication.CustomHeaders)]);
break;
}

if (Authentication.CustomHeaders.Count == 0)
{
yield return new ValidationResult(
$"The {nameof(Authentication.CustomHeaders)} configuration has no headers defined." +
$" Use \"{nameof(Authentication.Type)}\": \"{nameof(MirrorAuthenticationType.None)}\" instead if you intend you use no authentication.",
[nameof(Authentication.CustomHeaders)]);
}
break;
}
Expand Down

0 comments on commit 96c0dd1

Please sign in to comment.