Skip to content

Commit

Permalink
Allow underscore in alphanumberic key name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyRonning committed Feb 28, 2025
1 parent 08f6aff commit 006925d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/web/platform/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lazy_static! {
// - Underscore and dot for technical names (_.)
// - Spaces (will be trimmed)
static ref ALPHANUMERIC_WITH_SYMBOLS: Regex = Regex::new(r"^[a-zA-Z0-9\s&@!()\-+._]+$").unwrap();
static ref ALPHANUMERIC_ONLY: Regex = Regex::new(r"^[a-zA-Z0-9]+$").unwrap();
static ref ALPHANUMERIC_ONLY: Regex = Regex::new(r"^[a-zA-Z0-9_]+$").unwrap();
}

pub fn validate_alphanumeric_with_symbols(value: &str) -> Result<(), ValidationError> {
Expand Down Expand Up @@ -128,7 +128,7 @@ mod tests {
#[test]
fn test_alphanumeric_only() {
// Valid cases
let valid_strings = vec!["abc123", "ABC123", "123456", "abcABC123"];
let valid_strings = vec!["abc123", "ABC123", "123456", "abcABC123", "abc_123", "ABC_DEF", "RESEND_API_KEY"];

for s in valid_strings {
assert!(
Expand All @@ -140,7 +140,7 @@ mod tests {

// Invalid cases
let invalid_strings = vec![
"abc 123", "abc-123", "abc_123", "abc.123", "abc@123", "", " ", "abc!123",
"abc 123", "abc-123", "abc.123", "abc@123", "", " ", "abc!123",
];

for s in invalid_strings {
Expand Down

0 comments on commit 006925d

Please sign in to comment.