Skip to main content

is_valid_key

Function is_valid_key 

Source
pub fn is_valid_key(key: &str) -> bool
Expand description

Check that an event name or property key matches ^[a-zA-Z#][A-Za-z0-9_]{0,49}$ — a 1..=50 character identifier starting with a letter or #.

use thinkingdata_core::utils::is_valid_key;

assert!(is_valid_key("product_name"));
assert!(is_valid_key("#lib"));
assert!(!is_valid_key("9invalid"));