using System.Text.RegularExpressions; namespace Omika.HfSqlProbe; internal static partial class SqlIdentifierValidator { /// Accepts only letters, digits, and underscores. [GeneratedRegex(@"\A[A-Za-z_][A-Za-z0-9_]*\z")] private static partial Regex IdentifierPattern(); public static bool IsValid(string name) => IdentifierPattern().IsMatch(name); /// Validates and returns the identifier, or throws on invalid input. public static string Validate(string name) { if (!IsValid(name)) throw new ArgumentException( $"Invalid SQL identifier: '{name}'. Only [A-Za-z0-9_] allowed."); return name; } }