| 1 | using System.Text.RegularExpressions; |
| 2 | |
| 3 | namespace AgentForge.Plugin.Sdk; |
| 4 | |
| 5 | public static partial class ForgeSlug |
| 6 | { |
| 7 | private static readonly Regex SlugPattern = SlugRegex(); |
| 8 | |
| 9 | public static bool IsValid(string? value) => |
| 10 | !string.IsNullOrWhiteSpace(value) && SlugPattern.IsMatch(value.Trim()); |
| 11 | |
| 12 | public static string Normalize(string value) => value.Trim().ToLowerInvariant(); |
| 13 | |
| 14 | [GeneratedRegex("^[a-z][a-z0-9-]{0,61}[a-z0-9]$|^[a-z]$", RegexOptions.CultureInvariant)] |
| 15 | private static partial Regex SlugRegex(); |
| 16 | } |
| 17 | |
View only · write via MCP/CIDE