Update regex

This commit is contained in:
2025-06-09 01:39:27 +07:00
parent ca1301e837
commit 664e45f888
2 changed files with 76 additions and 3 deletions

View File

@@ -168,13 +168,13 @@ public class UserService : IUserService
public async Task<User> UpdateTelegramChannel(User user, string telegramChannel)
{
// Validate Telegram channel format (must start with @ and contain only allowed characters)
// Validate Telegram channel format (numeric channel ID only)
if (!string.IsNullOrEmpty(telegramChannel))
{
string pattern = @"^@[a-zA-Z0-9_]{5,32}$";
string pattern = @"^[0-9]{5,15}$";
if (!Regex.IsMatch(telegramChannel, pattern))
{
throw new Exception("Invalid Telegram channel format. Must start with @ and be 5-32 characters long, containing only letters, numbers, and underscores.");
throw new Exception("Invalid Telegram channel format. Must be numeric channel ID (5-15 digits).");
}
}