initial commit

This commit is contained in:
2026-04-07 17:41:25 +02:00
commit 1ed9bdfa55
45 changed files with 4712 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Package validation provides input validation utilities.
package validation
import (
"strings"
)
// CleanUsername removes email domain suffixes from username.
// ProtonVPN usernames don't include the email domain.
func CleanUsername(username string) string {
username = strings.TrimSpace(username)
username = strings.TrimSuffix(username, "@protonmail.com")
username = strings.TrimSuffix(username, "@proton.me")
username = strings.TrimSuffix(username, "@pm.me")
return username
}
// IsValidCountryCode checks if a country code is valid (2 letters).
func IsValidCountryCode(code string) bool {
return len(code) == 2 && isAlpha(code)
}
// isAlpha checks if a string contains only alphabetic characters.
func isAlpha(s string) bool {
for _, r := range s {
if (r < 'A' || r > 'Z') && (r < 'a' || r > 'z') {
return false
}
}
return true
}