Added a check for characters which an API key cannot contain (#1227)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-24 17:20:13 +01:00
1 parent c72a1948b3
commit e5a7f5423f
40 files changed
+1179 -71

No files matched your search

@@ -0,0 +1,20 @@
namespace AIStudio.Tools.Validation;
/// <summary>
/// The first character of an API key which cannot be sent.
/// </summary>
/// <remarks>
/// The key itself never goes in here: this value ends up in messages, and its kind in the log.
/// Only a character the user can see is kept, so that a message can name it.
/// </remarks>
/// <param name="Kind">What is wrong with the character.</param>
/// <param name="Character">The character as the user sees it, or empty unless it is a visible character outside of ASCII.</param>
public readonly record struct APIKeyIssue(APIKeyIssueKind Kind, string Character)
{
public static readonly APIKeyIssue NONE = new(APIKeyIssueKind.NONE, string.Empty);
/// <summary>
/// Whether the key cannot be sent.
/// </summary>
public bool IsProblem => this.Kind is not APIKeyIssueKind.NONE;
}